Total Complexity | 7 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
29 | final class Reference implements ReferenceInterface |
||
30 | { |
||
31 | private string $id; |
||
32 | private bool $optional; |
||
33 | |||
34 | /** |
||
35 | * @param mixed $id |
||
36 | * |
||
37 | * @throws InvalidConfigException |
||
38 | */ |
||
39 | 10 | private function __construct($id, bool $optional) |
|
40 | { |
||
41 | 10 | if (!is_string($id)) { |
|
42 | 1 | throw new InvalidConfigException('Reference ID must be string.'); |
|
43 | } |
||
44 | |||
45 | 9 | $this->id = $id; |
|
46 | 9 | $this->optional = $optional; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @throws InvalidConfigException If ID is not string. |
||
51 | */ |
||
52 | 9 | public static function to($id): self |
|
53 | { |
||
54 | 9 | return new self($id, false); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param mixed $id ID of the service or object to point to. |
||
59 | * |
||
60 | * @throws InvalidConfigException If ID is not string. |
||
61 | */ |
||
62 | 1 | public static function optional($id): self |
|
65 | } |
||
66 | |||
67 | 3 | public function resolve(ContainerInterface $container) |
|
72 |