| Total Complexity | 6 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class ClosureContainer implements ContainerInterface |
||
| 11 | { |
||
| 12 | private Closure $factory; |
||
| 13 | private array $definitions; |
||
| 14 | |||
| 15 | public function __construct(Closure $factory, array $definitions = []) |
||
| 16 | { |
||
| 17 | $this->factory = $factory; |
||
| 18 | $this->definitions = $definitions; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function get($id) |
||
| 22 | { |
||
| 23 | if (!$this->has($id)) { |
||
| 24 | $this->definitions[$id] = ($this->factory)($id); |
||
| 25 | } |
||
| 26 | return $this->definitions[$id]; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function has($id) |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |