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.

RGBToHEXConverter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsFrom() 0 3 1
A convert() 0 14 1
A supportsTo() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Color\Converter;
6
7
use Artack\Color\Color\Color;
8
use Artack\Color\Color\HEX;
9
use Artack\Color\Color\RGB;
10
use Webmozart\Assert\Assert;
11
12
class RGBToHEXConverter implements ConverterInterface
13
{
14 131
    public function convert(Color $color): Color
15
    {
16
        /* @var RGB $color */
17 131
        Assert::isInstanceOf($color, RGB::class, sprintf('color should be an instance of [%s]', RGB::class));
18
19 130
        $red = dechex($color->getRed());
20 130
        $green = dechex($color->getGreen());
21 130
        $blue = dechex($color->getBlue());
22
23 130
        $red = str_pad($red, 2, '0', STR_PAD_LEFT);
24 130
        $green = str_pad($green, 2, '0', STR_PAD_LEFT);
25 130
        $blue = str_pad($blue, 2, '0', STR_PAD_LEFT);
26
27 130
        return new HEX($red, $green, $blue);
28
    }
29
30 924
    public static function supportsFrom(): string
31
    {
32 924
        return RGB::class;
33
    }
34
35 924
    public static function supportsTo(): string
36
    {
37 924
        return HEX::class;
38
    }
39
}
40