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::has()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 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