Skip to content

Commit 75487eb

Browse files
committed
correction
Signed-off-by: rahul <[email protected]>
1 parent 6de83b5 commit 75487eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/FileHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function close(): void
5353
}
5454
}
5555

56-
public function searchInCsvFile(string $keyword, string $column, string|null $format = null): bool
56+
public function searchInCsvFile(string $keyword, string $column, string|null $format = null): bool|array
5757
{
5858
return $this->search($keyword, $column, $format);
5959
}
@@ -83,7 +83,7 @@ private function search(string $keyword, string $column, string|null $format): b
8383
{
8484
foreach ($this->getRows() as $row) {
8585
if ($keyword === $row[$column]) {
86-
return ($format === self::ARRAY_FORMAT) ? $row[$column] : true;
86+
return ($format === self::ARRAY_FORMAT) ? $row : true;
8787
}
8888
}
8989
return false;

tests/FileHandlerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public function to_array_method_returns_valid_array()
115115
{
116116
$data = $this->fileHandler->open(filename: 'movie.csv')->toArray();
117117

118+
print_r($data);
119+
118120
$expected = [
119121
'Film' => 'Zack and Miri Make a Porno',
120122
'Genre' => 'Romance',
@@ -130,6 +132,7 @@ public function to_array_method_returns_valid_array()
130132
$this->assertEquals($expected, $data[0]);
131133
}
132134

135+
#[Test]
133136
public function search_by_keyword_and_return_array()
134137
{
135138
$expected = [

0 commit comments

Comments
 (0)