HasContainerTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 35
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 6 1
A getContainer() 0 4 1
A hasContainer() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Container\Traits;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Psr\Container\ContainerInterface;
22
23
/**
24
 * @package Limoncello\Flute
25
 */
26
trait HasContainerTrait
27
{
28
    /**
29
     * @var null|ContainerInterface
30
     */
31
    private $container = null;
32
33
    /**
34
     * @param ContainerInterface $container
35
     *
36 1
     * @return self
37
     */
38 1
    protected function setContainer(ContainerInterface $container): self
39
    {
40 1
        $this->container = $container;
41
42
        return $this;
43
    }
44
45
    /**
46 1
     * @return ContainerInterface
47
     */
48 1
    protected function getContainer(): ContainerInterface
49
    {
50
        return $this->container;
51
    }
52
53
    /**
54 1
     * @return bool
55
     */
56 1
    protected function hasContainer(): bool
57
    {
58
        return $this->container !== null;
59
    }
60
}
61