Passed
Push — master ( 5acb2c...3be486 )
by Gabriel
07:50
created

Command   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Test Coverage

Coverage 92.59%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 119
ccs 25
cts 27
cp 0.9259
rs 10
wmc 13

12 Methods

Rating   Name   Duplication   Size   Complexity  
A hasNamespaces() 0 3 1
A getAlias() 0 3 1
A getNamespaces() 0 3 2
A getInstance() 0 3 1
A setInstance() 0 3 1
A getConfiguration() 0 3 1
A hasInstance() 0 3 1
A setAlias() 0 3 1
A hasConfiguration() 0 3 1
A setConfiguration() 0 3 1
A getTries() 0 3 1
A addTry() 0 3 1
1
<?php
2
3
4
namespace Nip\Records\Locator\Resolver\Commands;
5
6
use Nip\Records\AbstractModels\RecordManager;
7
use Nip\Records\Instantiator\HasInstantiatorTrait;
8
use Nip\Records\Locator\Configuration\Configuration;
9
use Nip\Records\Registry\HasModelRegistry;
10
use Nip\Records\Registry\ModelRegistry;
11
12
/**
13
 * Class Command
14
 * @package Nip\Records\Locator\Resolver\Commands
15
 */
16
class Command
17
{
18
    use HasInstantiatorTrait;
19
    use HasModelRegistry;
20
21
    /**
22
     * @var string
23
     */
24
    protected $alias;
25
26
    /**
27
     * @var Configuration
28
     */
29
    protected $configuration;
30
31
    /**
32
     * @var []
0 ignored issues
show
Documentation Bug introduced by
The doc comment [] at position 0 could not be parsed: Unknown type name '[' at position 0 in [].
Loading history...
33
     */
34
    protected $tries = [];
35
36
    /**
37
     * @var RecordManager
38
     */
39
    protected $instance = null;
40
41
    /**
42
     * @return string
43
     */
44 3
    public function getAlias(): string
45
    {
46 3
        return $this->alias;
47
    }
48
49
    /**
50
     * @param string $alias
51
     */
52 3
    public function setAlias(string $alias)
53
    {
54 3
        $this->alias = $alias;
55 3
    }
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 3
    public function getConfiguration(): Configuration
69
    {
70 3
        return $this->configuration;
71
    }
72
73
    /**
74
     * @param Configuration $configuration
75
     */
76 3
    public function setConfiguration(Configuration $configuration)
77
    {
78 3
        $this->configuration = $configuration;
79 3
    }
80
81
    /**
82
     * @return bool
83
     */
84 3
    public function hasInstance()
85
    {
86 3
        return $this->getInstance() instanceof RecordManager;
87
    }
88
89
    /**
90
     * @return RecordManager|null
91
     */
92 3
    public function getInstance()
93
    {
94 3
        return $this->instance;
95
    }
96
97
    /**
98
     * @param RecordManager $instance
99
     */
100 2
    public function setInstance(RecordManager $instance)
101
    {
102 2
        $this->instance = $instance;
103 2
    }
104
105
    /**
106
     * @return bool
107
     */
108 3
    public function hasNamespaces()
109
    {
110 3
        return $this->getConfiguration()->hasNamespaces();
111
    }
112
113
    /**
114
     * @return array
115
     */
116 2
    public function getNamespaces()
117
    {
118 2
        return $this->hasNamespaces() ? $this->getConfiguration()->getNamespaces() : [];
119
    }
120
121
    /**
122
     * @return ModelRegistry
123
     */
124 1
    public function getTries(): array
125
    {
126 1
        return $this->tries;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->tries returns the type array which is incompatible with the documented return type Nip\Records\Registry\ModelRegistry.
Loading history...
127
    }
128
129
    /**
130
     * @param $class
131
     */
132 3
    public function addTry($class)
133
    {
134 3
        $this->tries[] = $class;
135 3
    }
136
}
137