Conditions | 9 |
Paths | 9 |
Total Lines | 31 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
75 | public function isValid($input = null) |
||
76 | { |
||
77 | if ($input === null || $input === '') { |
||
78 | return false; |
||
79 | } |
||
80 | |||
81 | $input = (string) $input; |
||
82 | |||
83 | if (!$invalidCharset = !@mb_check_encoding($input, $this->charset)) { |
||
84 | $length = mb_strlen($input, $this->charset); |
||
85 | } |
||
86 | |||
87 | if ($invalidCharset) { |
||
88 | $this->violations[] = 'charset'; |
||
89 | |||
90 | return false; |
||
91 | } |
||
92 | |||
93 | if ($this->max !== null && $length > $this->max) { |
||
|
|||
94 | $this->violations[] = 'max'; |
||
95 | |||
96 | return false; |
||
97 | } |
||
98 | |||
99 | if ($this->min !== null && $length < $this->min) { |
||
100 | $this->violations[] = 'min'; |
||
101 | |||
102 | return false; |
||
103 | } |
||
104 | |||
105 | return true; |
||
106 | } |
||
108 |