Skip to content

Commit b6d6f82

Browse files
committed
OXDEV-8213: Move order of filter condition check
1 parent 5a8179a commit b6d6f82

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

CHANGELOG-v9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010
- `DataType\Filter\AbstractNumberFilter`
11+
- `DataType\Filter\StringFilter::matches()` to check if string match the filter conditions
1112

1213
### Changed
1314
- Use `DataType\Filter\AbstractNumberFilter` for `DataType\Filter\IntegerFilter` and `DataType\Filter\FloatFilter`

src/DataType/Filter/StringFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public function contains(): ?string
4444

4545
public function matches(string $value): bool
4646
{
47-
if ($this->contains !== null && !str_contains($value, $this->contains)) {
47+
if ($this->equals !== null && $value !== $this->equals) {
4848
return false;
4949
}
5050

51-
if ($this->equals !== null && $value !== $this->equals) {
51+
if ($this->contains !== null && !str_contains($value, $this->contains)) {
5252
return false;
5353
}
5454

tests/Unit/DataType/Filter/StringFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static function matchesDataProvider(): \Generator
171171

172172
yield "test match begins with " => [
173173
'stringForTrueCase' => 'this start',
174-
'stringForFalseCase' => 'this deos not start with',
174+
'stringForFalseCase' => 'this does not start with',
175175
'initFilter' => new StringFilter(beginsWith: 'this start')
176176
];
177177
}

0 commit comments

Comments
 (0)