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

ContainerRegistry   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getContainer() 0 7 2
A addContainer() 0 8 2
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