Skip to content

Commit 5348dfc

Browse files
committed
Change LessThan and GreaterThan "limit" to "value"
This is more consistent with other matchers: - Equals takes a "value" - Contains takes "values"
1 parent 0d06426 commit 5348dfc

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/Matcher/Matcher/GreaterThan.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public function __construct(
1919
private Field $field,
2020
#[FilterOrValidator(new ToNumber())]
21-
private float|int $limit,
21+
private float|int $value,
2222
private bool $inclusive = true,
2323
) {}
2424

@@ -28,7 +28,7 @@ public function matches(DTO $dto): bool
2828

2929
return is_numeric($value)
3030
&& ($this->inclusive
31-
? $value >= $this->limit
32-
: $value > $this->limit);
31+
? $value >= $this->value
32+
: $value > $this->value);
3333
}
3434
}

src/Matcher/Matcher/LessThan.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public function __construct(
1919
private Field $field,
2020
#[FilterOrValidator(new ToNumber())]
21-
private float|int $limit,
21+
private float|int $value,
2222
private bool $inclusive = true,
2323
) {}
2424

@@ -28,7 +28,7 @@ public function matches(DTO $dto): bool
2828

2929
return is_numeric($value)
3030
&& ($this->inclusive
31-
? $value <= $this->limit
32-
: $value < $this->limit);
31+
? $value <= $this->value
32+
: $value < $this->value);
3333
}
3434
}

tests/unit/Matcher/MatcherFactory/GreaterThanTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function provideConfigs(): \Generator
4242
),
4343
[
4444
'field' => ['path', 'pet', 'age'],
45-
'limit' => 1,
45+
'value' => 1,
4646
],
4747
];
4848
yield 'implicitly >= "1"' => [
@@ -53,7 +53,7 @@ public static function provideConfigs(): \Generator
5353
),
5454
[
5555
'field' => ['path', 'pet', 'age'],
56-
'limit' => '1',
56+
'value' => '1',
5757
],
5858
];
5959
yield 'implicitly >= 3.14' => [
@@ -64,7 +64,7 @@ public static function provideConfigs(): \Generator
6464
),
6565
[
6666
'field' => ['path', 'pet', 'age'],
67-
'limit' => 3.14,
67+
'value' => 3.14,
6868
],
6969
];
7070

@@ -76,7 +76,7 @@ public static function provideConfigs(): \Generator
7676
),
7777
[
7878
'field' => ['path', 'pet', 'age'],
79-
'limit' => 2,
79+
'value' => 2,
8080
'inclusive' => true,
8181
],
8282
];
@@ -88,7 +88,7 @@ public static function provideConfigs(): \Generator
8888
),
8989
[
9090
'field' => ['path', 'pet', 'age'],
91-
'limit' => '2',
91+
'value' => '2',
9292
'inclusive' => true,
9393
],
9494
];
@@ -100,7 +100,7 @@ public static function provideConfigs(): \Generator
100100
),
101101
[
102102
'field' => ['path', 'pet', 'age'],
103-
'limit' => 9.81,
103+
'value' => 9.81,
104104
'inclusive' => true,
105105
],
106106
];
@@ -113,7 +113,7 @@ public static function provideConfigs(): \Generator
113113
),
114114
[
115115
'field' => ['path', 'pet', 'age'],
116-
'limit' => 3,
116+
'value' => 3,
117117
'inclusive' => false,
118118
],
119119
];
@@ -125,7 +125,7 @@ public static function provideConfigs(): \Generator
125125
),
126126
[
127127
'field' => ['path', 'pet', 'age'],
128-
'limit' => '3',
128+
'value' => '3',
129129
'inclusive' => false,
130130
],
131131
];

tests/unit/Matcher/MatcherFactory/LessThanTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function provideConfigs(): \Generator
4242
),
4343
[
4444
'field' => ['path', 'pet', 'age'],
45-
'limit' => 1,
45+
'value' => 1,
4646
],
4747
];
4848
yield 'implicitly <= "1"' => [
@@ -53,7 +53,7 @@ public static function provideConfigs(): \Generator
5353
),
5454
[
5555
'field' => ['path', 'pet', 'age'],
56-
'limit' => '1',
56+
'value' => '1',
5757
],
5858
];
5959
yield 'implicitly <= 3.14' => [
@@ -64,7 +64,7 @@ public static function provideConfigs(): \Generator
6464
),
6565
[
6666
'field' => ['path', 'pet', 'age'],
67-
'limit' => 3.14,
67+
'value' => 3.14,
6868
],
6969
];
7070

@@ -76,7 +76,7 @@ public static function provideConfigs(): \Generator
7676
),
7777
[
7878
'field' => ['path', 'pet', 'age'],
79-
'limit' => 2,
79+
'value' => 2,
8080
'inclusive' => true,
8181
],
8282
];
@@ -88,7 +88,7 @@ public static function provideConfigs(): \Generator
8888
),
8989
[
9090
'field' => ['path', 'pet', 'age'],
91-
'limit' => '2',
91+
'value' => '2',
9292
'inclusive' => true,
9393
],
9494
];
@@ -100,7 +100,7 @@ public static function provideConfigs(): \Generator
100100
),
101101
[
102102
'field' => ['path', 'pet', 'age'],
103-
'limit' => 9.81,
103+
'value' => 9.81,
104104
'inclusive' => true,
105105
],
106106
];
@@ -113,7 +113,7 @@ public static function provideConfigs(): \Generator
113113
),
114114
[
115115
'field' => ['path', 'pet', 'age'],
116-
'limit' => 3,
116+
'value' => 3,
117117
'inclusive' => false,
118118
],
119119
];
@@ -125,7 +125,7 @@ public static function provideConfigs(): \Generator
125125
),
126126
[
127127
'field' => ['path', 'pet', 'age'],
128-
'limit' => '3',
128+
'value' => '3',
129129
'inclusive' => false,
130130
],
131131
];

0 commit comments

Comments
 (0)