| Conditions | 3 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 13 | public static function validate(string $string): array |
|
| 36 | { |
||
| 37 | 13 | $errors = []; |
|
| 38 | |||
| 39 | 13 | if (str_starts_with($string, '.')) { |
|
| 40 | 1 | $errors[] = 'The string cannot starts with .'; |
|
| 41 | } |
||
| 42 | |||
| 43 | // check for string length |
||
| 44 | 13 | if (strlen(urlencode($string)) > 221) { |
|
| 45 | 1 | $errors[] = 'The string is too long (max length of urlencoded string is 221 bytes)'; |
|
| 46 | } |
||
| 47 | |||
| 48 | 13 | return $errors; |
|
| 49 | } |
||
| 51 |