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