| Conditions | 3 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function validate($data): Result |
||
| 27 | { |
||
| 28 | $result = (new StringType())->validate($data); |
||
| 29 | |||
| 30 | if (!$result->isValid()) |
||
| 31 | return new $result; |
||
| 32 | |||
| 33 | if (ctype_alnum(str_replace($this->allowedSpecialChars, '', $data))) |
||
| 34 | return new Success(); |
||
| 35 | else |
||
| 36 | return new Failure(new RuleError(RuleErrorCode::NOT_ALNUM, 'String is not Alphanumeric.')); |
||
| 37 | } |
||
| 38 | } |