Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | 15 | public function __construct(mixed $value) |
|
13 | { |
||
14 | 15 | if (\is_array($value)) { |
|
15 | 4 | if (!isset($value['base'])) { |
|
16 | 1 | throw new InvalidArgumentException( |
|
17 | 1 | 'If you want to build an URI from an array, use the schema: [ base => string, ?parameters => [string => mixed]' |
|
18 | 1 | ); |
|
19 | } |
||
20 | |||
21 | 3 | $parameters = $value['parameters'] ?? []; |
|
22 | 3 | $value = str_replace(array_keys($parameters), $parameters, (string) $value['base']); |
|
23 | 11 | } elseif (!\is_string($value)) { |
|
24 | 4 | throw new InvalidArgumentException('$value must be a string or an array.'); |
|
25 | } |
||
26 | 10 | $this->uri = $value; |
|
|
|||
27 | } |
||
34 |