Total Complexity | 6 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | #[Attribute(Attribute::TARGET_PROPERTY)] |
||
10 | class NumberBetween extends AbstractValidation |
||
11 | { |
||
12 | const MESSAGE = 'The value should be between `%s` and `%s` (%sincluding the boundaries)'; |
||
13 | |||
14 | public function __construct( |
||
15 | private int|float $min, |
||
16 | private int|float $max, |
||
17 | private $boundaries = true, |
||
18 | ?string $message = null |
||
19 | ) { |
||
20 | $this->message = |
||
21 | $message ?? |
||
22 | sprintf( |
||
23 | self::MESSAGE, |
||
24 | $this->min, |
||
25 | $this->max, |
||
26 | !$this->boundaries ? 'not ' : '' |
||
27 | ); |
||
28 | parent::__construct($message); |
||
29 | } |
||
30 | |||
31 | protected function evaluate($input, array $context = []): bool |
||
38 | } |
||
39 | } |
||
40 |