GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CompositeContainer   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 9
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 66
ccs 20
cts 20
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A addContainer() 0 6 1
A get() 0 11 3
A has() 0 11 3
1
<?php
2
3
namespace Acclimate\Container;
4
5
use Interop\Container\ContainerInterface;
6
use Acclimate\Container\Exception\NotFoundException;
7
8
/**
9
 * A composite container that acts as a normal container, but delegates method calls to one or more internal containers
10
 */
11
class CompositeContainer implements ContainerInterface
12
{
13
    /**
14
     * @var array Containers that are contained within this composite container
15
     */
16
    protected $containers = array();
17
18
    /**
19
     * @param array $containers Containers to add to this composite container
20
     */
21 3
    public function __construct(array $containers = array())
22
    {
23 3
        foreach ($containers as $container) {
24 1
            $this->addContainer($container);
25 3
        }
26 3
    }
27
28
    /**
29
     * Adds a container to an internal queue of containers
30
     *
31
     * @param ContainerInterface $container The container to add
32
     *
33
     * @return $this
34
     */
35 2
    public function addContainer(ContainerInterface $container)
36
    {
37 2
        $this->containers[] = $container;
38
39 2
        return $this;
40
    }
41
42
    /**
43
     * Finds an entry of the container by delegating the get call to a FIFO queue of internal containers
44
     *
45
     * {@inheritDoc}
46
     */
47 3
    public function get($id)
48
    {
49
        /** @var ContainerInterface $container */
50 3
        foreach ($this->containers as $container) {
51 2
            if ($container->has($id)) {
52 1
                return $container->get($id);
53
            }
54 2
        }
55
56 2
        throw NotFoundException::fromPrevious($id);
57
    }
58
59
    /**
60
     * Returns true if the at least one of the internal containers can return an entry for the given identifier
61
     * Returns false otherwise.
62
     *
63
     * {@inheritDoc}
64
     */
65 3
    public function has($id)
66
    {
67
        /** @var ContainerInterface $container */
68 3
        foreach ($this->containers as $container) {
69 2
            if ($container->has($id)) {
70 1
                return true;
71
            }
72 2
        }
73
74 2
        return false;
75
    }
76
}
77