HasModelRegistry   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getModelRegistry() 0 6 2
A setModelRegistry() 0 3 1
A initModelRegistry() 0 3 1
A generateModelRegistry() 0 3 1
1
<?php
2
3
namespace Nip\Records\Registry;
4
5
/**
6
 * Trait HasModelRegistry
7
 * @package Nip\Records\Registry
8
 */
9
trait HasModelRegistry
10
{
11
    /**
12
     * @var ModelRegistry;
13
     */
14
    protected $modelRegistry = null;
15
16
    /**
17
     * @return ModelRegistry
18
     */
19 29
    public function getModelRegistry()
20
    {
21 29
        if ($this->modelRegistry === null) {
22 1
            $this->initModelRegistry();
23
        }
24 29
        return $this->modelRegistry;
25
    }
26
27
    /**
28
     * @param modelRegistry $modelRegistry
29
     */
30 4
    public function setModelRegistry(ModelRegistry $modelRegistry)
31
    {
32 4
        $this->modelRegistry = $modelRegistry;
33 4
    }
34
35 1
    protected function initModelRegistry()
36
    {
37 1
        $this->modelRegistry = $this->generateModelRegistry();
38 1
    }
39
40
    /**
41
     * @return ModelRegistry
42
     */
43 1
    protected function generateModelRegistry()
44
    {
45 1
        return new ModelRegistry();
46
    }
47
}
48