Passed
Pull Request — master (#6)
by
unknown
01:51
created

ContainerRegistry::addContainer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Everlution\Navigation\Advanced;
4
5
use Everlution\Navigation\Advanced\Item\AdvancedNavigationInterface;
6
7
/**
8
 * Class ContainerRegistry
9
 * @author Martin Lutter <[email protected]>
10
 */
11
class ContainerRegistry
12
{
13
    /** @var AdvancedNavigationInterface[] */
14
    private $containers = [];
15
16
    public function addContainer(AdvancedNavigationInterface $container)
17
    {
18
        $containerName = get_class($container);
19
        if (array_key_exists($containerName, $this->containers)) {
20
            throw new ContainerAlreadyRegisteredException($containerName);
0 ignored issues
show
Bug introduced by
The type Everlution\Navigation\Ad...eadyRegisteredException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
        }
22
23
        $this->containers[$containerName] = $container;
24
    }
25
26
    public function getContainer(string $containerName): AdvancedNavigationInterface
27
    {
28
        if (false === array_key_exists($containerName, $this->containers)) {
29
            throw new ContainerIsNotRegisteredException($containerName);
0 ignored issues
show
Bug introduced by
The type Everlution\Navigation\Ad...sNotRegisteredException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
        }
31
32
        return $this->containers[$containerName];
33
    }
34
}
35