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

HasConfigurationTrait::getConfiguration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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