Lines
80.00%
4 / 5
Methods
66.66%
2 / 3
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| get | 66.66% | 2 / 3 | 0.00% | 0 / 1 | 2.15 | ||
| has | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| set | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 20 | class Container extends \ArrayObject implements ContainerInterface | |
| 21 | { | |
| 22 | /** | |
| 23 | * @param string $id | |
| 24 | * @return mixed | |
| 25 | * | |
| 26 | * @throws NotFoundExceptionInterface | |
| 27 | */ | |
| 28 | #[\Override] | |
| 29 | public function get(string $id) | |
| 30 | { | |
| 31 | if (!$this->has($id)) { | |
| 32 | throw new UnknownIdentifierException('The container has no value identified by ' . $id); | |
| 33 | } | |
| 34 | ||
| 35 | return $this->offsetGet($id); | |
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * @param string $id The value identifier | |
| 40 | * | |
| 41 | * @return bool | |
| 42 | */ | |
| 43 | #[\Override] | |
| 44 | public function has(string $id): bool | |
| 45 | { | |
| 46 | return $this->offsetExists($id); | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @param string $identifier | |
| 51 | * @param mixed $value | |
| 52 | */ | |
| 53 | public function set(string $identifier, $value): void | |
| 54 | { | |
| 55 | $this->offsetSet($identifier, $value); | |
| 56 | } | |
| 57 | } |