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.

Validate   A
last analyzed

Complexity

Total Complexity 22

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 69
c 0
b 0
f 0
wmc 22
lcom 0
cbo 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A rgbChannelValue() 0 6 3
A alphaChannelValue() 0 6 3
A hexChannelValue() 0 10 3
A hslValue() 0 6 3
A rgbColorString() 0 6 2
A rgbaColorString() 0 6 2
A hexColorString() 0 6 2
A hslColorString() 0 6 2
A hslaColorString() 0 6 2
1
<?php
2
3
namespace Spatie\Color;
4
5
use Spatie\Color\Exceptions\InvalidColorValue;
6
7
class Validate
8
{
9
    public static function rgbChannelValue(int $value, string $channel)
10
    {
11
        if ($value < 0 || $value > 255) {
12
            throw InvalidColorValue::rgbChannelValueNotInRange($value, $channel);
13
        }
14
    }
15
16
    public static function alphaChannelValue(float $value)
17
    {
18
        if ($value < 0 || $value > 1) {
19
            throw InvalidColorValue::alphaChannelValueNotInRange($value);
20
        }
21
    }
22
23
    public static function hexChannelValue(string $value)
24
    {
25
        if (strlen($value) !== 2) {
26
            throw InvalidColorValue::hexChannelValueHasInvalidLength($value);
27
        }
28
29
        if (! preg_match('/[a-f0-9]{2}/i', $value)) {
30
            throw InvalidColorValue::hexValueContainsInvalidCharacters($value);
31
        }
32
    }
33
34
    public static function hslValue(float $value, string $name)
35
    {
36
        if ($value < 0 || $value > 100) {
37
            throw InvalidColorValue::hslValueNotInRange($value, $name);
38
        }
39
    }
40
41
    public static function rgbColorString($string)
42
    {
43
        if (! preg_match('/^ *rgb\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *\) *$/i', $string)) {
44
            throw InvalidColorValue::malformedRgbColorString($string);
45
        }
46
    }
47
48
    public static function rgbaColorString($string)
49
    {
50
        if (! preg_match('/^ *rgba\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1](\.\d{1,2})? *\) *$/i', $string)) {
51
            throw InvalidColorValue::malformedRgbaColorString($string);
52
        }
53
    }
54
55
    public static function hexColorString($string)
56
    {
57
        if (! preg_match('/^#[a-f0-9]{6}$/i', $string)) {
58
            throw InvalidColorValue::malformedHexColorString($string);
59
        }
60
    }
61
62
    public static function hslColorString($string)
63
    {
64
        if (! preg_match('/^ *hsl\( *-?\d{1,3} *, *\d{1,3}%? *, *\d{1,3}%? *\) *$/i', $string)) {
65
            throw InvalidColorValue::malformedHslColorString($string);
66
        }
67
    }
68
69
    public static function hslaColorString($string)
70
    {
71
        if (! preg_match('/^ *hsla\( *\d{1,3} *, *\d{1,3}%? *, *\d{1,3}%? *, *[0-1](\.\d{1,2})? *\) *$/i', $string)) {
72
            throw InvalidColorValue::malformedHslaColorString($string);
73
        }
74
    }
75
}
76