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