Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 7 |
Lines | 3 |
Ratio | 17.65 % |
Changes | 0 |
1 | <?php |
||
16 | public function loadStatus(Configuration $config): Status |
||
17 | { |
||
18 | $serviceName = $config->getServiceName(); |
||
19 | |||
20 | if (!isset($this->store[$serviceName])) { |
||
21 | return new Status($config); |
||
22 | } |
||
23 | |||
24 | /** @var $status Status */ |
||
25 | list($ttl, $status) = array_values($this->store[$serviceName]); |
||
26 | |||
27 | // If a ttl was stored with the status and it is outdated, the default status (closed breaker) is returned |
||
28 | View Code Duplication | if ($ttl !== 0 && $status->getLastUpdate() + $ttl < time()) { |
|
|
|||
29 | $status = new Status($config); |
||
30 | } |
||
31 | |||
32 | return $status; |
||
33 | } |
||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.