Completed
Push — master ( 0ba58c...dd341e )
by Gabriel
07:12
created

Command::getTries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 []
33
     */
34
    protected $tries = [];
35
36
    /**
37
     * @var RecordManager
38
     */
39
    protected $instance = null;
40
41
    /**
42
     * @return string
43
     */
44 9
    public function getAlias(): string
45
    {
46 9
        return $this->alias;
47
    }
48
49
    /**
50
     * @param string $alias
51
     */
52 9
    public function setAlias(string $alias)
53
    {
54 9
        $this->alias = $alias;
55 9
    }
56
57
    /**
58
     * @return bool
59
     */
60
    public function hasConfiguration()
61
    {
62
        return $this->getConfiguration() instanceof Configuration;
63
    }
64
65
    /**
66
     * @return Configuration
67
     */
68 2
    public function getConfiguration(): Configuration
69
    {
70 2
        return $this->configuration;
71
    }
72
73
    /**
74
     * @param Configuration $configuration
75
     */
76 9
    public function setConfiguration(Configuration $configuration): void
77
    {
78 9
        $this->configuration = $configuration;
79 9
    }
80
81
    /**
82
     * @return bool
83
     */
84 9
    public function hasInstance()
85
    {
86 9
        return $this->getInstance() instanceof RecordManager;
87
    }
88
89
    /**
90
     * @return RecordManager|null
91
     */
92 9
    public function getInstance()
93
    {
94 9
        return $this->instance;
95
    }
96
97
    /**
98
     * @param RecordManager $instance
99
     */
100 8
    public function setInstance(RecordManager $instance)
101
    {
102 8
        $this->instance = $instance;
103 8
    }
104
105
    /**
106
     * @return bool
107
     */
108 2
    public function hasNamespaces()
109
    {
110 2
        return $this->getConfiguration()->hasNamespaces();
111
    }
112
113
    /**
114
     * @return array
115
     */
116 1
    public function getNamespaces()
117
    {
118 1
        return $this->hasNamespaces() ? $this->getConfiguration()->getNamespaces() : [];
119
    }
120
121
    /**
122
     * @return ModelRegistry
123
     */
124 9
    public function getModelRegistry(): ModelRegistry
125
    {
126 9
        return $this->modelRegistry;
127
    }
128
129
    /**
130
     * @param ModelRegistry $modelRegistry
131
     */
132 9
    public function setModelRegistry(ModelRegistry $modelRegistry)
133
    {
134 9
        $this->modelRegistry = $modelRegistry;
135 9
    }
136
137
    /**
138
     * @return ModelRegistry
139
     */
140 1
    public function getTries(): array
141
    {
142 1
        return $this->tries;
143
    }
144
145
    /**
146
     * @param $class
147
     */
148 3
    public function addTry($class)
149
    {
150 3
        $this->tries[] = $class;
151 3
    }
152
}
153