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.
Test Failed
Push — master ( 003f3e...5f1f5d )
by Patrick
02:17
created

Converter::getConverterTo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Color;
6
7
use Artack\Color\Color\Color;
8
use Artack\Color\Converter\Convertible;
9
10
class Converter
11
{
12
    /** @var Convertible[] */
13
    private $converters = [];
14
15
    /**
16
     * @param Convertible[] $converters
17
     */
18
    public function __construct(array $converters)
19
    {
20
        foreach ($converters as $converter) {
21
            $this->addConverter($converter);
22
        }
23
    }
24
25
    private function addConverter(Convertible $converter)
26
    {
27
        $this->converters[] = $converter;
28
    }
29
30
    public function convert(Color $color, string $fqcn): Color
31
    {
32
        foreach ($this->getConverterChain([], \get_class($color), $fqcn) as $converter) {
33
            $color = $converter->convert($color);
34
        }
35
36
        return $color;
37
    }
38
39
    /**
40
     * @param Convertible[] $converters
41
     * @param string        $fromFqcn
42
     * @param string        $toFqcn
43
     *
44
     * @return Convertible[]
45
     */
46
    private function getConverterChain(array $converters, string $fromFqcn, string $toFqcn): array
47
    {
48
        foreach ($this->converters as $converter) {
49
            if ($converter::supportsFrom() === $fromFqcn) {
50
                $converters[] = $converter;
51
52
                if ($converter::supportsTo() === $toFqcn) {
53
                    return $converters;
54
                }
55
56
                return $this->getConverterChain($converters, $converter::supportsTo(), $toFqcn);
57
            }
58
        }
59
60
        return $converters;
61
    }
62
}
63