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.

HEX::getRed()   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\Color;
6
7
use Artack\Color\Exception\InvalidArgumentException;
8
9
class HEX extends Color
10
{
11
    private $red;
12
    private $green;
13
    private $blue;
14
15 341
    public function __construct(string $red, string $green, string $blue)
16
    {
17 341
        $pattern = '/^[0-9a-f]{1,2}$/i';
18
19 341
        if (!preg_match($pattern, $red)) {
20 4
            throw new InvalidArgumentException(sprintf('Given red value %s need so to be a valid 2 character hex string', $red));
21
        }
22 337
        if (!preg_match($pattern, $green)) {
23 4
            throw new InvalidArgumentException(sprintf('Given red value %s need so to be a valid 2 character hex string', $green));
24
        }
25 333
        if (!preg_match($pattern, $blue)) {
26 4
            throw new InvalidArgumentException(sprintf('Given red value %s need so to be a valid 2 character hex string', $blue));
27
        }
28
29 329
        $this->red = $red;
30 329
        $this->green = $green;
31 329
        $this->blue = $blue;
32 329
    }
33
34 195
    public function __toString()
35
    {
36 195
        return sprintf('%02x%02x%02x', hexdec($this->red), hexdec($this->green), hexdec($this->blue));
37
    }
38
39 133
    public function getRed(): string
40
    {
41 133
        return $this->red;
42
    }
43
44 133
    public function getGreen(): string
45
    {
46 133
        return $this->green;
47
    }
48
49 133
    public function getBlue(): string
50
    {
51 133
        return $this->blue;
52
    }
53
}
54