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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
- Chg #165: Simplify `FilterInterface` and `FilterHandlerInterface` (@vjik)
- Chg #166: Remove `EqualsEmpty` filter (@vjik)
- New #176: Add `OrderHelper` (@vjik)
- New #173, #184: Add `$caseSensitive` parameter to `Like` filter to control whether the search must be case-sensitive
or not (@arogachev)
- New #173, #184, #220: Add `$caseSensitive` parameter to `Like` filter to control whether the search must be
case-sensitive or not (@arogachev, @vjik)
- Enh #187, #196: Limit set in data reader is now taken into account by offset paginator. Keyset paginator throws
an exception in this case (@samdark, @vjik)
- Chg #187: Add `FilterableDataInterface::getFilter()`, `LimitableDataInterface::getLimit()`,
Expand Down
2 changes: 1 addition & 1 deletion src/Reader/Filter/Like.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getValue(): string
return $this->value;
}

public function isCaseSensitive(): ?bool
public function getCaseSensitive(): ?bool
{
return $this->caseSensitive;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Reader/Iterable/FilterHandler/LikeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function match(object|array $item, FilterInterface $filter, array $iterab
return false;
}

return $filter->isCaseSensitive() === true
return $filter->getCaseSensitive() === true
? str_contains($itemValue, $filter->getValue())
: mb_stripos($itemValue, $filter->getValue()) !== false;
}
Expand Down
29 changes: 29 additions & 0 deletions tests/Reader/Filter/LikeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Data\Tests\Reader\Filter;

use Yiisoft\Data\Reader\Filter\Like;
use Yiisoft\Data\Tests\TestCase;

final class LikeTest extends TestCase
{
public function testBase(): void
{
$like = new Like('name', 'Kesha');

$this->assertSame('name', $like->getField());
$this->assertSame('Kesha', $like->getValue());
$this->assertNull($like->getCaseSensitive());
}

public function testWithCaseSensitive(): void
{
$like = new Like('name', 'Kesha', true);

$this->assertSame('name', $like->getField());
$this->assertSame('Kesha', $like->getValue());
$this->assertTrue($like->getCaseSensitive());
}
}
Loading