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

HasConfigurationTrait::initConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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