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

HasModelRegistry   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
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 getModelRegistry() 0 7 2
A setModelRegistry() 0 4 1
A initModelRegistry() 0 4 1
1
<?php
2
3
namespace Nip\Records\Locator\Registry;
4
5
/**
6
 * Trait HasModelRegistry
7
 * @package Nip\Records\Locator\Registry
8
 */
9
trait HasModelRegistry
10
{
11
    /**
12
     * @var ModelRegistry;
13
     */
14
    protected $modelRegistry = null;
15
16
    /**
17
     * @return ModelRegistry
18
     */
19 6
    public function getModelRegistry()
20
    {
21 6
        if ($this->modelRegistry === null) {
22 1
            $this->initModelRegistry();
23
        }
24 6
        return $this->modelRegistry;
25
    }
26
27
    /**
28
     * @param modelRegistry $modelRegistry
29
     */
30
    protected function setModelRegistry(ModelRegistry $modelRegistry)
31
    {
32
        $this->modelRegistry = $modelRegistry;
33
    }
34
35
36 1
    protected function initModelRegistry()
37
    {
38 1
        $this->modelRegistry = (new ModelRegistry);
39 1
    }
40
}
41