HasConfigurationTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 30
ccs 6
cts 9
cp 0.6667
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initConfiguration() 0 3 1
A getConfiguration() 0 6 2
A setConfiguration() 0 3 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 9
    public function getConfiguration()
20
    {
21 9
        if ($this->configuration === null) {
22 1
            $this->initConfiguration();
23
        }
24 9
        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