Skip to content

Commit af32a4c

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

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public function studio_is_found_for_exact_name_match(string $keyword)
114114
public function to_array_method_returns_valid_array()
115115
{
116116
$data = $this->fileHandler->open(filename: 'movie.csv')->toArray();
117-
118117
$expected = [
119118
'Film' => 'Zack and Miri Make a Porno',
120119
'Genre' => 'Romance',
@@ -130,6 +129,7 @@ public function to_array_method_returns_valid_array()
130129
$this->assertEquals($expected, $data[0]);
131130
}
132131

132+
#[Test]
133133
public function search_by_keyword_and_return_array()
134134
{
135135
$expected = [

0 commit comments

Comments
 (0)