Total Complexity | 1 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class UriValidator implements ValidatorInterface |
||
17 | { |
||
18 | protected string $regex = '/^(https?):\/\/'. // protocol |
||
19 | '(([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+'. // username |
||
20 | '(:([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+)?'. // password |
||
21 | '@)?(?#'. // auth requires @ |
||
22 | ')((([a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*'. // domain segments AND |
||
23 | '[a-z][a-z0-9-]*[a-z0-9]'. // top level domain OR |
||
24 | '|((\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5])\.){3}'. |
||
25 | '(\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5])'. // IP address |
||
26 | ')(:\d+)?'. // port |
||
27 | ')(((\/+([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)*'. // path |
||
28 | '(\?([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)'. // query string |
||
29 | '?)?)?'. // path and query string optional |
||
30 | '(#([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)?'. // fragment |
||
31 | '$/i'; |
||
32 | |||
33 | public function isValid(mixed $toValidate): bool |
||
38 |