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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 31
ccs 17
cts 17
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A convert() 0 19 1
A supportsTo() 0 3 1
A supportsFrom() 0 3 1
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