Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
21 | public function validate($data) : Result |
||
22 | { |
||
23 | $result = (new StringType())->validate($data); |
||
24 | |||
25 | if (!$result->isValid()) |
||
26 | return new $result; |
||
27 | |||
28 | if (mb_strlen($data, 'UTF-8') <= $this->maxLength) { |
||
29 | return new Success(); |
||
30 | } |
||
31 | else return new Failure( |
||
32 | new RuleError(RuleErrorCode::LENGTH_ERROR, |
||
33 | 'The supplied string is too long')); |
||
34 | } |
||
35 | } |