| Total Complexity | 6 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 62.5% |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | trait ContainerAwareTrait |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var \Nip\Container\ContainerInterface |
||
| 13 | */ |
||
| 14 | protected $container; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Get the container. |
||
| 18 | * |
||
| 19 | * @return \Nip\Container\ContainerInterface |
||
| 20 | */ |
||
| 21 | 3 | public function getContainer() |
|
| 22 | { |
||
| 23 | 3 | return $this->container; |
|
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Set a container. |
||
| 28 | * |
||
| 29 | * @param \Nip\Container\ContainerInterface $container |
||
| 30 | * @return $this |
||
| 31 | */ |
||
| 32 | 2 | public function setContainer(ContainerInterface $container) |
|
| 33 | { |
||
| 34 | 2 | $this->container = $container; |
|
| 35 | 2 | return $this; |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | public function initContainer() |
|
| 39 | { |
||
| 40 | 1 | $container = Container::getInstance(); |
|
| 41 | 1 | if ($container instanceof Container) { |
|
|
|
|||
| 42 | 1 | $this->container = $container; |
|
| 43 | } else { |
||
| 44 | $this->container = $this->newContainer(); |
||
| 45 | Container::setInstance($this->container); |
||
| 46 | } |
||
| 47 | 1 | } |
|
| 48 | |||
| 49 | /** |
||
| 50 | * @return Container |
||
| 51 | */ |
||
| 52 | public function newContainer() |
||
| 53 | { |
||
| 54 | return new Container(); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | public function hasContainer() |
||
| 63 | } |
||
| 64 | } |
||
| 65 |