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

Command::hasConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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