Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- New #173, #184: Add `$caseSensitive` parameter to `Like` filter to control whether the search must be case-sensitive
or not (@arogachev)
- Chg #163: Rename `FilterableDataInterface::withFilterHandlers()` to `FilterableDataInterface::withAddedFilterHandlers()` (@samdark)
- Enh #190: Use `str_contains` for case-sensitive match in `LikeHandler` (@samdark)

## 1.0.1 January 25, 2023

Expand Down
3 changes: 1 addition & 2 deletions src/Reader/Iterable/FilterHandler/LikeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public function match(object|array $item, FilterInterface $filter, array $iterab
return false;
}

/** @infection-ignore-all MBString No suitable test case was found yet. */
return $filter->isCaseSensitive() === true
? mb_strpos($itemValue, $filter->getValue()) !== false
? str_contains($itemValue, $filter->getValue())
: mb_stripos($itemValue, $filter->getValue()) !== false;
}
}
2 changes: 2 additions & 0 deletions tests/Reader/Iterable/FilterHandler/LikeHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static function matchDataProvider(): array
[false, ['id' => 1, 'value' => 'Great Cat Fighter'], 'id', '1', true],
[true, ['id' => 1, 'value' => '🙁🙂🙁'], 'value', '🙂', true],
[true, ['id' => 1, 'value' => 'Привет мир'], 'value', ' ', true],

[true, ['id' => 1, 'value' => 'das Öl'], 'value', 'öl', false],
];
}

Expand Down