| Conditions | 4 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.0218 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | 38 | public static function validate($value, array $options = [], ?Model $model = null) |
|
| 16 | { |
||
| 17 | 38 | if ($value === null) { |
|
| 18 | 4 | return $value; |
|
| 19 | } |
||
| 20 | 38 | if (!is_string($value)) { |
|
| 21 | throw new ValidatorException('Expected a string.'); |
||
| 22 | } |
||
| 23 | 38 | $maxlength = $options['value']; |
|
| 24 | 38 | if (mb_strlen($value) > $maxlength) { |
|
| 25 | 1 | throw new ValidatorException('String is too long.'); |
|
| 26 | } |
||
| 27 | 37 | return $value; |
|
| 28 | } |
||
| 45 |