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 Setup Failed
Push — master ( 5f1f5d...227952 )
by Patrick
02:34
created

Factory::getConverterGraph()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 4
nop 0
dl 0
loc 16
rs 9.4285
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\Color\HEX;
9
use Artack\Color\Color\HSV;
10
use Artack\Color\Color\RGB;
11
use Artack\Color\Converter\Convertible;
12
use Artack\Color\Converter\HEXToRGBConverter;
13
use Artack\Color\Converter\HSVToRGBConverter;
14
use Artack\Color\Converter\RGBToHEXConverter;
15
use Artack\Color\Converter\RGBToHSVConverter;
16
use Artack\Color\Transition\HSVTransition;
17
use Artack\Color\Transition\RGBTransition;
18
use Artack\Color\Transition\TransitionInterface;
19
use Fhaculty\Graph\Graph;
20
use Fhaculty\Graph\Vertex;
21
22
class Factory
23
{
24
    const GRAPH_EDGE_KEY_CONVERTER = 'converter';
25
26
    /**
27
     * @return Convertible[]
28
     */
29
    public static function getConverters(): array
30
    {
31
        return [
32
            new RGBToHSVConverter(),
33
            new HSVToRGBConverter(),
34
            new RGBToHEXConverter(),
35
            new HEXToRGBConverter(),
36
        ];
37
    }
38
39
    /**
40
     * @return Color[]
41
     */
42
    public static function getColors(): array
43
    {
44
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(Artack\Colo...Color\Color\HEX::class) returns the type array<integer,string> which is incompatible with the documented return type Artack\Color\Color\Color[].
Loading history...
45
            RGB::class,
46
            HSV::class,
47
            HEX::class,
48
        ];
49
    }
50
51
    /**
52
     * @return TransitionInterface[]
53
     */
54
    public static function getTransitions(): array
55
    {
56
        return [
57
            new RGBTransition(),
58
            new HSVTransition(),
59
        ];
60
    }
61
62
    public static function getConverterGraph(): Graph
63
    {
64
        $graph = new Graph();
65
66
        /** @var Vertex[] $vertices */
67
        $vertices = [];
68
69
        foreach (self::getColors() as $color) {
70
            $vertices[$color] = $graph->createVertex($color);
71
        }
72
73
        foreach (self::getConverters() as $converter) {
74
            $vertices[$converter::supportsFrom()]->createEdgeTo($vertices[$converter::supportsTo()])->setAttribute(self::GRAPH_EDGE_KEY_CONVERTER, $converter);
75
        }
76
77
        return $graph;
78
    }
79
}
80