GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StaticServiceManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A get() 0 8 2
A getAll() 0 4 1
A getActive() 0 10 2
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\ShariffBundle\Manager;
11
12
use Core23\ShariffBundle\Service\Service;
13
14
final class StaticServiceManager implements ServiceManager
15
{
16
    /**
17
     * @var array<string, Service>
18
     */
19
    private $services;
20
21
    /**
22
     * @var array
23
     */
24
    private $active;
25
26
    public function __construct(array $services = [], array $active = [])
27
    {
28
        $this->services = [];
29
30
        foreach ($services as $service) {
31
            \assert($service instanceof Service);
32
33
            $this->services[$service->getCode()] = $service;
34
        }
35
36
        $this->active = $active;
37
    }
38
39
    public function get(string $code): ?Service
40
    {
41
        if (!isset($this->services[$code])) {
42
            return null;
43
        }
44
45
        return $this->services[$code];
46
    }
47
48
    public function getAll(): array
49
    {
50
        return array_values($this->services);
51
    }
52
53
    public function getActive(): array
54
    {
55
        if (0 === \count($this->active)) {
56
            return $this->getAll();
57
        }
58
59
        return array_filter(array_map(function (string $code) {
60
            return $this->get($code);
61
        }, $this->active));
62
    }
63
}
64