Completed
Push — master ( c5047e...3a177f )
by Gabriel
03:52
created

HasConfigurationTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 32
ccs 7
cts 10
cp 0.7
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 7 2
A setConfiguration() 0 4 1
A initConfiguration() 0 4 1
1
<?php
2
3
namespace Nip\Records\Locator\Configuration;
4
5
/**
6
 * Trait HasConfigurationTrait
7
 * @package Nip\Records\Locator\Configuration
8
 */
9
trait HasConfigurationTrait
10
{
11
    /**
12
     * @var null|Configuration
13
     */
14
    protected $configuration = null;
15
16
    /**
17
     * @return Configuration
18
     */
19 6
    public function getConfiguration()
20
    {
21 6
        if ($this->configuration === null) {
22 1
            $this->initConfiguration();
23
        }
24 6
        return $this->configuration;
25
    }
26
27
    /**
28
     * @param Configuration $configuration
29
     */
30
    public function setConfiguration(Configuration $configuration): void
31
    {
32
        $this->configuration = $configuration;
33
    }
34
35
36 1
    public function initConfiguration()
37
    {
38 1
        $this->configuration = (new Configuration);
39 1
    }
40
}
41