| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 11 | class MinLength implements ValidatorInterface |
||
| 12 | { |
||
| 13 | public function validate($value, array $validators = [], Model $model = null) |
||
| 14 | { |
||
| 15 | if (!is_string($value)) { |
||
| 16 | throw new \Formularium\Exception\ValidatorException('Expected a string.'); |
||
| 17 | } |
||
| 18 | |||
| 19 | $maxlength = $options['value']; |
||
| 20 | if (mb_strlen($value) < $options[self::MIN_LENGTH]) { |
||
| 21 | throw new \Formularium\Exception\ValidatorException('String is too short.'); |
||
| 22 | } |
||
| 23 | return $value; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function getMetadata(): ValidatorMetadata |
||
| 36 | ) |
||
| 37 | ] |
||
| 41 |