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.

Factory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 29
c 2
b 1
f 0
dl 0
loc 69
ccs 26
cts 26
cp 1
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createConverter() 0 3 1
A createTransition() 0 3 1
A getColors() 0 8 1
A getConverterGraph() 0 16 3
A getConverters() 0 11 1
A getTransitions() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Color;
6
7
use Artack\Color\Color\CMYK;
8
use Artack\Color\Color\HEX;
9
use Artack\Color\Color\HSL;
10
use Artack\Color\Color\HSV;
11
use Artack\Color\Color\RGB;
12
use Artack\Color\Converter\CMYKToRGBConverter;
13
use Artack\Color\Converter\ConverterInterface;
14
use Artack\Color\Converter\HEXToRGBConverter;
15
use Artack\Color\Converter\HSLToRGBConverter;
16
use Artack\Color\Converter\HSVToRGBConverter;
17
use Artack\Color\Converter\RGBToCMYKConverter;
18
use Artack\Color\Converter\RGBToHEXConverter;
19
use Artack\Color\Converter\RGBToHSLConverter;
20
use Artack\Color\Converter\RGBToHSVConverter;
21
use Artack\Color\Transition\HSVTransition;
22
use Artack\Color\Transition\RGBTransition;
23
use Artack\Color\Transition\TransitionInterface;
24
use Fhaculty\Graph\Graph;
25
use Fhaculty\Graph\Vertex;
26
27
class Factory
28
{
29
    const GRAPH_EDGE_KEY_CONVERTER = 'converter';
30
31 924
    public static function createConverter(): Converter
32
    {
33 924
        return new Converter(new ConverterGraph(self::getConverterGraph()));
34
    }
35
36 7
    public static function createTransition(): Transition
37
    {
38 7
        return new Transition(self::getTransitions(), self::createConverter());
39
    }
40
41
    /**
42
     * @return ConverterInterface[]
43
     */
44 924
    private static function getConverters(): array
45
    {
46
        return [
47 924
            new RGBToHSVConverter(),
48 924
            new HSVToRGBConverter(),
49 924
            new RGBToHEXConverter(),
50 924
            new HEXToRGBConverter(),
51 924
            new CMYKToRGBConverter(),
52 924
            new RGBToCMYKConverter(),
53 924
            new HSLToRGBConverter(),
54 924
            new RGBToHSLConverter(),
55
        ];
56
    }
57
58 924
    private static function getColors(): array
59
    {
60
        return [
61 924
            RGB::class,
62
            HSV::class,
63
            HSL::class,
64
            HEX::class,
65
            CMYK::class,
66
        ];
67
    }
68
69
    /**
70
     * @return TransitionInterface[]
71
     */
72 7
    private static function getTransitions(): array
73
    {
74
        return [
75 7
            new RGBTransition(),
76 7
            new HSVTransition(),
77
        ];
78
    }
79
80 924
    private static function getConverterGraph(): Graph
81
    {
82 924
        $graph = new Graph();
83
84
        /** @var Vertex[] $vertices */
85 924
        $vertices = [];
86
87 924
        foreach (self::getColors() as $color) {
88 924
            $vertices[$color] = $graph->createVertex($color);
0 ignored issues
show
Bug introduced by
$color of type string is incompatible with the type integer|null expected by parameter $id of Fhaculty\Graph\Graph::createVertex(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
            $vertices[$color] = $graph->createVertex(/** @scrutinizer ignore-type */ $color);
Loading history...
89
        }
90
91 924
        foreach (self::getConverters() as $converter) {
92 924
            $vertices[$converter::supportsFrom()]->createEdgeTo($vertices[$converter::supportsTo()])->setAttribute(self::GRAPH_EDGE_KEY_CONVERTER, $converter);
93
        }
94
95 924
        return $graph;
96
    }
97
}
98