Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
5 | class Between implements SanitizeRuleInterface |
||
6 | { |
||
7 | /** @var int */ |
||
8 | protected $min; |
||
9 | |||
10 | /** @var int */ |
||
11 | protected $max; |
||
12 | |||
13 | /** |
||
14 | * @param int $min The minimum value. |
||
15 | * @param int $max The maximum value. |
||
16 | */ |
||
17 | 24 | public function __construct(int $min, int $max) |
|
21 | 24 | } |
|
22 | |||
23 | /** |
||
24 | * Check that the value is within the given range. |
||
25 | * |
||
26 | * If the value is greater than the max, assign it to the max. If it is lower than the min, assign it to the min. |
||
27 | * |
||
28 | * @param object $subject The subject to be filtered. |
||
29 | * @param string $field The subject field name. |
||
30 | * |
||
31 | * @return bool True if the value was sanitized, false if not. |
||
32 | */ |
||
33 | 24 | public function __invoke($subject, string $field): bool |
|
52 |