Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
LeagueContainer
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 has
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 add
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @author: Doug Wilbourne (dougwilbourne@gmail.com)
5 */
6
7declare(strict_types=1);
8
9namespace pvc\html\htmlBuilder\definitions\implementations\league;
10
11use League\Container\Container;
12use League\Container\Definition\DefinitionInterface;
13use League\Container\ReflectionContainer;
14use pvc\interfaces\html\htmlBuilder\definitions\AbstractDefinitionFactoryInterface;
15use pvc\interfaces\html\htmlBuilder\HtmlContainerInterface;
16
17/**
18 * Class HtmlLeagueContainer
19 * @template VendorSpecificDefinition of AbstractDefinitionFactoryInterface
20 * @implements HtmlContainerInterface<VendorSpecificDefinition<DefinitionInterface>>
21 */
22class LeagueContainer implements HtmlContainerInterface
23{
24    /**
25     * @var Container
26     */
27    protected Container $container;
28
29    /**
30     * @param Container $container
31     */
32    public function __construct(Container $container)
33    {
34        $this->container = $container;
35
36        /**
37         * enable autowiring
38         */
39        $this->container->delegate(new ReflectionContainer());
40    }
41
42    /**
43     * has
44     * @param string $id
45     * @return bool
46     */
47    public function has(string $id): bool
48    {
49        return $this->container->has($id);
50    }
51
52    /**
53     * get
54     * @param string $id
55     * @return mixed
56     * @throws \Psr\Container\ContainerExceptionInterface
57     * @throws \Psr\Container\NotFoundExceptionInterface
58     */
59    public function get(string $id): mixed
60    {
61        return $this->container->get($id);
62    }
63
64    /**
65     * add
66     * @param string $defId
67     * @param DefinitionInterface|null $definition
68     */
69    public function add(string $defId, mixed $definition = null): void
70    {
71        $this->container->add($defId, $definition);
72    }
73}