Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
33 | 24 | public function __invoke($subject, string $field): bool |
|
34 | { |
||
35 | 24 | $value = $subject->$field; |
|
36 | 24 | if (!is_scalar($value)) { |
|
37 | 3 | return false; |
|
38 | } |
||
39 | |||
40 | 21 | if ($value < $this->min) { |
|
41 | 6 | $subject->$field = $this->min; |
|
42 | } |
||
43 | |||
44 | 21 | if ($value > $this->max) { |
|
45 | 6 | $subject->$field = $this->max; |
|
46 | } |
||
47 | |||
48 | |||
49 | 21 | return true; |
|
50 | } |
||
52 |