Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function validate($data) : Result |
||
35 | { |
||
36 | $result = (new StringType())->validate($data); |
||
37 | |||
38 | if (!$result->isValid()) |
||
39 | return new $result; |
||
40 | |||
41 | if (mb_strlen($data, 'UTF-8') == $this->length) { |
||
42 | return new Success(); |
||
43 | } |
||
44 | else return new Failure( |
||
45 | new RuleError(RuleErrorCode::LENGTH_ERROR, |
||
46 | 'The supplied string is not of correct length')); |
||
47 | } |
||
48 | } |