EmptyContainer::getFirst()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Caridea
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
 * use this file except in compliance with the License. You may obtain a copy of
8
 * the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 * License for the specific language governing permissions and limitations under
16
 * the License.
17
 *
18
 * @copyright 2015-2018 LibreWorks contributors
19
 * @license   Apache-2.0
20
 */
21
namespace Caridea\Container;
22
23
/**
24
 * Empty, no-op dependency injection container.
25
 */
26
class EmptyContainer implements Container
27
{
28
    /**
29
     * {@inheritDoc}
30
     */
31 1
    public function contains(string $name): bool
32
    {
33 1
        return false;
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 1
    public function containsType(string $type): bool
40
    {
41 1
        return false;
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 1
    public function get($id)
48
    {
49 1
        throw new Exception\Missing("No container entry found for key: $id");
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55 1
    public function getByType(string $type): array
56
    {
57 1
        return [];
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63 1
    public function getFirst(string $type)
64
    {
65 1
        return null;
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71 1
    public function getNames(): array
72
    {
73 1
        return [];
74
    }
75
76
    /**
77
     * {@inheritDoc}
78
     */
79 1
    public function getParent(): ?Container
80
    {
81 1
        return null;
82
    }
83
84
    /**
85
     * {@inheritDoc}
86
     */
87 1
    public function getType(string $name): ?string
88
    {
89 1
        return null;
90
    }
91
92
    /**
93
     * {@inheritDoc}
94
     */
95
    public function has($id): bool
96
    {
97
        return false;
98
    }
99
100
    /**
101
     * {@inheritDoc}
102
     */
103 1
    public function named(string $name, string $type)
104
    {
105 1
        throw new \UnexpectedValueException("A $type was requested, but null was found");
106
    }
107
}
108