Conditions | 4 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
38 | 21 | public function __invoke($subject, string $field): bool |
|
39 | { |
||
40 | 21 | $value = $subject->$field; |
|
41 | 21 | if (!is_scalar($value)) { |
|
42 | 3 | return false; |
|
43 | } |
||
44 | 18 | if ($this->strlen($value) < $this->len) { |
|
45 | 6 | $subject->$field = $this->strpad($value, $this->len, $this->padString, $this->padType); |
|
46 | } |
||
47 | 18 | if ($this->strlen($value) > $this->len) { |
|
48 | 6 | $subject->$field = $this->substr($value, 0, $this->len); |
|
49 | } |
||
50 | |||
51 | 18 | return true; |
|
52 | } |
||
54 |