Total Complexity | 8 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class UrlsWithPlaceholders implements ValueObjectInterface |
||
12 | { |
||
13 | use StringTrait; |
||
14 | |||
15 | /** |
||
16 | * @var string[]|null |
||
17 | */ |
||
18 | private $placeholders; |
||
19 | |||
20 | protected function validValue(string $value): bool |
||
21 | { |
||
22 | $identifier = '(\w|-|{\w+})+'; |
||
23 | $scheme = '^' . $identifier . '://'; |
||
24 | $username = $identifier . '(:' . $identifier . ')?'; |
||
25 | $hostname = $identifier . '(\.' . $identifier . ')*'; |
||
26 | $path = '/(.|{\w+})*'; |
||
27 | $regex = '#' . $scheme . '(' . $username . '@)?' . $hostname . '(' . $path . ')*$#i'; |
||
28 | return preg_match($regex, $value) ? true : false; |
||
29 | } |
||
30 | |||
31 | public function getPlaceholders() |
||
40 | } |
||
41 | |||
42 | public function replace(array $replacements): Url |
||
49 | } |
||
50 | |||
51 | protected function sanitizeValue(string $value): string |
||
54 | } |
||
55 | } |