| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class InfiniteRecursionDetector implements ContainerInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var ContainerInterface |
||
| 14 | */ |
||
| 15 | private $container; |
||
| 16 | /** |
||
| 17 | * @var string[] |
||
| 18 | */ |
||
| 19 | private $calls = []; |
||
| 20 | |||
| 21 | 9 | public function __construct(ContainerInterface $container) |
|
| 24 | 9 | } |
|
| 25 | |||
| 26 | 6 | public function get($id) |
|
| 27 | { |
||
| 28 | 6 | if (in_array($id, $this->calls)) { |
|
| 29 | 3 | throw new InfiniteRecursion($id, $this->calls); |
|
| 30 | } |
||
| 31 | 6 | $this->calls[] = $id; |
|
| 32 | 6 | $result = $this->container->get($id); |
|
| 33 | 3 | array_pop($this->calls); |
|
| 34 | 3 | return $result; |
|
| 35 | } |
||
| 36 | |||
| 37 | 3 | public function has($id): bool |
|
| 40 | } |
||
| 41 | } |
||
| 42 |