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.

CMYKToRGBConverter::supportsFrom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Color\Converter;
6
7
use Artack\Color\Color\CMYK;
8
use Artack\Color\Color\Color;
9
use Artack\Color\Color\RGB;
10
use Webmozart\Assert\Assert;
11
12
class CMYKToRGBConverter implements ConverterInterface
13
{
14 65
    public function convert(Color $color): Color
15
    {
16
        /* @var CMYK $color */
17 65
        Assert::isInstanceOf($color, CMYK::class, sprintf('color should be an instance of [%s]', CMYK::class));
18
19 65
        $cyan = $color->getCyan() / 100;
20 65
        $magenta = $color->getMagenta() / 100;
21 65
        $yellow = $color->getYellow() / 100;
22 65
        $key = $color->getKey() / 100;
23
24 65
        $red = 1 - min(1, $cyan * (1 - $key) + $key);
25 65
        $green = 1 - min(1, $magenta * (1 - $key) + $key);
26 65
        $blue = 1 - min(1, $yellow * (1 - $key) + $key);
27
28 65
        $red *= 255;
29 65
        $green *= 255;
30 65
        $blue *= 255;
31
32 65
        return new RGB((int) round($red), (int) round($green), (int) round($blue));
33
    }
34
35 924
    public static function supportsFrom(): string
36
    {
37 924
        return CMYK::class;
38
    }
39
40 924
    public static function supportsTo(): string
41
    {
42 924
        return RGB::class;
43
    }
44
}
45