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

Command   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 13
lcom 2
cbo 1
dl 0
loc 118
ccs 26
cts 28
cp 0.9286
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
A setAlias() 0 4 1
A hasConfiguration() 0 4 1
A getConfiguration() 0 4 1
A setConfiguration() 0 4 1
A hasInstance() 0 4 1
A getInstance() 0 4 1
A setInstance() 0 4 1
A hasNamespaces() 0 4 1
A getNamespaces() 0 4 2
A getModelRegistry() 0 4 1
A setModelRegistry() 0 4 1
1
<?php
2
3
4
namespace Nip\Records\Locator\Resolver\Commands;
5
6
use Nip\Records\AbstractModels\RecordManager;
7
use Nip\Records\Locator\Configuration\Configuration;
8
use Nip\Records\Locator\Registry\ModelRegistry;
9
10
/**
11
 * Class Command
12
 * @package Nip\Records\Locator\Resolver\Commands
13
 */
14
class Command
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $alias;
20
21
    /**
22
     * @var Configuration
23
     */
24
    protected $configuration;
25
26
    /**
27
     * @var ModelRegistry
28
     */
29
    protected $modelRegistry;
30
31
    /**
32
     * @var RecordManager
33
     */
34
    protected $instance = null;
35
36
    /**
37
     * @return string
38
     */
39 6
    public function getAlias(): string
40
    {
41 6
        return $this->alias;
42
    }
43
44
    /**
45
     * @param string $alias
46
     */
47 6
    public function setAlias(string $alias)
48
    {
49 6
        $this->alias = $alias;
50 6
    }
51
52
    /**
53
     * @return bool
54
     */
55
    public function hasConfiguration()
56
    {
57
        return $this->getConfiguration() instanceof Configuration;
58
    }
59
60
    /**
61
     * @return Configuration
62
     */
63 2
    public function getConfiguration(): Configuration
64
    {
65 2
        return $this->configuration;
66
    }
67
68
    /**
69
     * @param Configuration $configuration
70
     */
71 6
    public function setConfiguration(Configuration $configuration): void
72
    {
73 6
        $this->configuration = $configuration;
74 6
    }
75
76
    /**
77
     * @return bool
78
     */
79 6
    public function hasInstance()
80
    {
81 6
        return $this->getInstance() instanceof RecordManager;
82
    }
83
84
    /**
85
     * @return RecordManager|null
86
     */
87 6
    public function getInstance()
88
    {
89 6
        return $this->instance;
90
    }
91
92
    /**
93
     * @param RecordManager $instance
94
     */
95 5
    public function setInstance(RecordManager $instance)
96
    {
97 5
        $this->instance = $instance;
98 5
    }
99
100
    /**
101
     * @return bool
102
     */
103 2
    public function hasNamespaces()
104
    {
105 2
        return $this->getConfiguration()->hasNamespaces();
106
    }
107
108
    /**
109
     * @return array
110
     */
111 1
    public function getNamespaces()
112
    {
113 1
        return $this->hasNamespaces() ? $this->getConfiguration()->getNamespaces() : [];
114
    }
115
116
    /**
117
     * @return ModelRegistry
118
     */
119 6
    public function getModelRegistry(): ModelRegistry
120
    {
121 6
        return $this->modelRegistry;
122
    }
123
124
    /**
125
     * @param ModelRegistry $modelRegistry
126
     */
127 6
    public function setModelRegistry(ModelRegistry $modelRegistry)
128
    {
129 6
        $this->modelRegistry = $modelRegistry;
130 6
    }
131
}
132