Skip to content

Commit e12b236

Browse files
authored
Rename isCaseSensitive() to getCaseSensitive() in Like (#220)
1 parent 9502a7f commit e12b236

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
- Chg #165: Simplify `FilterInterface` and `FilterHandlerInterface` (@vjik)
2626
- Chg #166: Remove `EqualsEmpty` filter (@vjik)
2727
- New #176: Add `OrderHelper` (@vjik)
28-
- New #173, #184: Add `$caseSensitive` parameter to `Like` filter to control whether the search must be case-sensitive
29-
or not (@arogachev)
28+
- New #173, #184, #220: Add `$caseSensitive` parameter to `Like` filter to control whether the search must be
29+
case-sensitive or not (@arogachev, @vjik)
3030
- Enh #187, #196: Limit set in data reader is now taken into account by offset paginator. Keyset paginator throws
3131
an exception in this case (@samdark, @vjik)
3232
- Chg #187: Add `FilterableDataInterface::getFilter()`, `LimitableDataInterface::getLimit()`,

src/Reader/Filter/Like.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getValue(): string
3737
return $this->value;
3838
}
3939

40-
public function isCaseSensitive(): ?bool
40+
public function getCaseSensitive(): ?bool
4141
{
4242
return $this->caseSensitive;
4343
}

src/Reader/Iterable/FilterHandler/LikeHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function match(object|array $item, FilterInterface $filter, array $iterab
3030
return false;
3131
}
3232

33-
return $filter->isCaseSensitive() === true
33+
return $filter->getCaseSensitive() === true
3434
? str_contains($itemValue, $filter->getValue())
3535
: mb_stripos($itemValue, $filter->getValue()) !== false;
3636
}

tests/Reader/Filter/LikeTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Data\Tests\Reader\Filter;
6+
7+
use Yiisoft\Data\Reader\Filter\Like;
8+
use Yiisoft\Data\Tests\TestCase;
9+
10+
final class LikeTest extends TestCase
11+
{
12+
public function testBase(): void
13+
{
14+
$like = new Like('name', 'Kesha');
15+
16+
$this->assertSame('name', $like->getField());
17+
$this->assertSame('Kesha', $like->getValue());
18+
$this->assertNull($like->getCaseSensitive());
19+
}
20+
21+
public function testWithCaseSensitive(): void
22+
{
23+
$like = new Like('name', 'Kesha', true);
24+
25+
$this->assertSame('name', $like->getField());
26+
$this->assertSame('Kesha', $like->getValue());
27+
$this->assertTrue($like->getCaseSensitive());
28+
}
29+
}

0 commit comments

Comments
 (0)