| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 35 | 528 | public function __construct($value) |
|
| 36 | { |
||
| 37 | 528 | if ($value === '') { |
|
| 38 | 1 | return; |
|
| 39 | } |
||
| 40 | |||
| 41 | 528 | if (!is_string($value)) { |
|
| 42 | 9 | throw new InvalidArgumentException('URI component "path" must be a string'); |
|
| 43 | } |
||
| 44 | |||
| 45 | 519 | $this->value = (string) preg_replace_callback( |
|
| 46 | 519 | self::NORMALIZATION_REGEX, |
|
| 47 | 519 | static fn(array $matches): string => ( |
|
| 48 | /** @var array{0: string, 1?: string} $matches */ |
||
| 49 | 519 | isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
| 50 | 519 | ), |
|
| 51 | 519 | $value, |
|
| 52 | 519 | ); |
|
| 65 |