Passed
Push — master ( 01baf6...9ed857 )
by Vitor de
04:10
created

Manager   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 199
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 3

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 20
c 1
b 0
f 0
lcom 3
cbo 3
dl 0
loc 199
ccs 44
cts 52
cp 0.8462
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __clone() 0 3 1
A getInstance() 0 8 2
A getConfiguration() 0 4 1
A setConfiguration() 0 5 1
A getApiClient() 0 10 2
A setLogger() 0 5 1
A getLogger() 0 4 1
A setApiClient() 0 5 1
A getCommandBus() 0 8 2
A setCommandBus() 0 5 1
A isEnabled() 0 4 1
A getContextManager() 0 4 1
A setContextManager() 0 5 1
A getServiceFactory() 0 4 1
A setServiceFactory() 0 5 1
A tearDown() 0 4 1
1
<?php
2
3
namespace GFG\Hek;
4
5
use GFG\DTOContext\Manager as ContextManager;
6
7
class Manager
8
{
9
    /**
10
     * @var Manager
11
     */
12
    private static $instance;
13
14
    /**
15
     * @var Interfaces\Configuration
16
     */
17
    private $configuration;
18
19
    /**
20
     * @var ApiClient
21
     */
22
    private $apiClient;
23
24
    /**
25
     * @var CommandBus
26
     */
27
    private $commandBus;
28
29
    /**
30
     * @var \Context\Manager
31
     */
32
    private $contextManager;
33
34
    /**
35
     * @var Interfaces\ServiceFactory
36
     */
37
    private $serviceFactory;
38
39
    /**
40
     * @var \Psr\Log\LoggerInterface
41
     */
42
    private $logger;
43
44 8
    private function __construct()
45
    {
46 8
    }
47
48
    /**
49
     * @return void
50
     */
51
    private function __clone()
52
    {
53
    }
54
55
    /**
56
     * @return Manager
57
     */
58 8
    public static function getInstance()
59
    {
60 8
        if (!self::$instance) {
61 8
            self::$instance = new self();
62 8
        }
63
64 8
        return self::$instance;
65
    }
66
67
    /**
68
     * @return Interfaces\Configuration
69
     */
70 2
    public function getConfiguration()
71
    {
72 2
        return $this->configuration;
73
    }
74
75
    /**
76
     * @param Interfaces\Configuration $configuration
77
     * @return Manager
78
     */
79 2
    public function setConfiguration(Interfaces\Configuration $configuration)
80
    {
81 2
        $this->configuration = $configuration;
82 2
        return $this;
83
    }
84
85
    /**
86
     * @return ApiClient
87
     */
88 1
    public function getApiClient()
89
    {
90 1
        if (!$this->apiClient) {
91
            $this->setApiClient(
92
                new ApiClient($this->getConfiguration(), $this->getLogger())
93
            );
94
        }
95
96 1
        return $this->apiClient;
97
    }
98
99
    /**
100
     * @param \Psr\Log\LoggerInterface
101
     * @return Manager
102
     */
103 1
    public function setLogger(\Psr\Log\LoggerInterface $logger)
104
    {
105 1
        $this->logger = $logger;
106 1
        return $this;
107
    }
108
109
    /**
110
     * @return \Psr\Log\LoggerInterface
111
     */
112 1
    public function getLogger()
113
    {
114 1
        return $this->logger;
115
    }
116
117
    /**
118
     * @param ApiClient $apiClient
119
     * @return Manager
120
     */
121 1
    public function setApiClient(ApiClient $apiClient)
122
    {
123 1
        $this->apiClient = $apiClient;
124 1
        return $this;
125
    }
126
127
    /**
128
     * @return CommandBus
129
     */
130 1
    public function getCommandBus()
131
    {
132 1
        if (!$this->commandBus) {
133
            $this->setCommandBus(new CommandBus($this));
134
        }
135
136 1
        return $this->commandBus;
137
    }
138
139
    /**
140
     * @param string name
141
     * @param CommandBus $commandBus
142
     * @return Manager
143
     */
144 1
    public function setCommandBus(CommandBus $commandBus)
145
    {
146 1
        $this->commandBus = $commandBus;
147 1
        return $this;
148
    }
149
150
    /**
151
     * @return bool
152
     */
153 1
    public function isEnabled()
154
    {
155 1
        return $this->getConfiguration()->isEnabled();
156
    }
157
    
158
    /**
159
     * @return void
160
     */
161 1
    public function getContextManager()
162
    {
163 1
        return $this->contextManager;
164
    }
165
166
    /**
167
     * Set a new context manager
168
     *
169
     * @param ContextManager $contextManager
170
     * @return Manager
171
     */
172 1
    public function setContextManager(ContextManager $contextManager)
173
    {
174 1
        $this->contextManager = $contextManager;
0 ignored issues
show
Documentation Bug introduced by
It seems like $contextManager of type object<GFG\DTOContext\Manager> is incompatible with the declared type object<Context\Manager> of property $contextManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
175 1
        return $this;
176
    }
177
178
    /**
179
     * @return Interfaces\ServiceFactory
180
     */
181 1
    public function getServiceFactory()
182
    {
183 1
        return $this->serviceFactory;
184
    }
185
186
    /**
187
     * @return Manager
188
     */
189 1
    public function setServiceFactory(Interfaces\ServiceFactory $serviceFactory)
190
    {
191 1
        $this->serviceFactory = $serviceFactory;
192 1
        return $this;
193
    }
194
195
    /**
196
     * Resets the static variable that contains the instance,
197
     * for test purposes
198
     *
199
     * @return void
200
     */
201 8
    public function tearDown()
202
    {
203 8
        self::$instance = null;
204 8
    }
205
}
206