Completed
Push — master ( d7d2c9...5a9def )
by Neomerx
03:39
created

HasContainerTrait   A

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 namespace Limoncello\Container\Traits;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of 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,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Psr\Container\ContainerInterface;
20
21
/**
22
 * @package Limoncello\Flute
23
 */
24
trait HasContainerTrait
25
{
26
    /**
27
     * @var null|ContainerInterface
28
     */
29
    private $container = null;
30
31
    /**
32
     * @param ContainerInterface $container
33
     *
34
     * @return self
35
     */
36 1
    protected function setContainer(ContainerInterface $container): self
37
    {
38 1
        $this->container = $container;
39
40 1
        return $this;
41
    }
42
43
    /**
44
     * @return ContainerInterface
45
     */
46 1
    protected function getContainer(): ContainerInterface
47
    {
48 1
        return $this->container;
49
    }
50
51
    /**
52
     * @return bool
53
     */
54 1
    protected function hasContainer(): bool
55
    {
56 1
        return $this->container !== null;
57
    }
58
}
59