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