| Conditions | 4 |
| Paths | 5 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | 39 | public function __invoke($subject, string $field): bool |
|
| 45 | { |
||
| 46 | 39 | $value = $subject->$field; |
|
| 47 | 39 | if (!is_scalar($value)) { |
|
| 48 | 3 | return false; |
|
| 49 | } |
||
| 50 | 36 | if ($this->strlen($value) < $this->min) { |
|
| 51 | 6 | $subject->$field = $this->strpad($value, $this->min, $this->padString, $this->padType); |
|
| 52 | } |
||
| 53 | 36 | if ($this->strlen($value) > $this->max) { |
|
| 54 | 12 | $subject->$field = $this->substr($value, 0, $this->max); |
|
| 55 | } |
||
| 56 | |||
| 57 | 36 | return true; |
|
| 58 | } |
||
| 60 |