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.

InvalidColorValue   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 59
c 0
b 0
f 0
wmc 11
lcom 1
cbo 0
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A rgbChannelValueNotInRange() 0 4 1
A alphaChannelValueNotInRange() 0 4 1
A hexChannelValueHasInvalidLength() 0 6 1
A hexValueContainsInvalidCharacters() 0 4 1
A hslValueNotInRange() 0 4 1
A malformedHexColorString() 0 4 1
A malformedHslColorString() 0 4 1
A malformedHslaColorString() 0 4 1
A malformedRgbColorString() 0 4 1
A malformedRgbaColorString() 0 4 1
A malformedColorString() 0 4 1
1
<?php
2
3
namespace Spatie\Color\Exceptions;
4
5
use Exception;
6
7
class InvalidColorValue extends Exception
8
{
9
    public static function rgbChannelValueNotInRange(int $value, string $channel): self
10
    {
11
        return new static("An rgb values must be an integer between 0 and 255, `{$value}` provided for channel {$channel}.");
12
    }
13
14
    public static function alphaChannelValueNotInRange(int $value): self
15
    {
16
        return new static("An alpha values must be a float between 0 and 1, `{$value}` provided.");
17
    }
18
19
    public static function hexChannelValueHasInvalidLength(string $value): self
20
    {
21
        $length = strlen($value);
22
23
        return new static("Hex values must contain exactly 2 characters, `{$value}` contains {$length} characters.");
24
    }
25
26
    public static function hexValueContainsInvalidCharacters(string $value): self
27
    {
28
        return new static("Hex values can only contain numbers or letters from A-F, `{$value}` contains invalid characters.");
29
    }
30
31
    public static function hslValueNotInRange(float $value, string $name): self
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        return new static("Hsl value `{$name}` must be a number between 0 and 100");
34
    }
35
36
    public static function malformedHexColorString(string $string): self
37
    {
38
        return new static("Hex color string `{$string}` is malformed. A hex color string starts with a `#` and contains exactly six characters, e.g. `#aabbcc`.");
39
    }
40
41
    public static function malformedHslColorString(string $string): self
42
    {
43
        return new static("Hsl color string `{$string}` is malformed. An hsl color contains hue, saturation, and lightness values, wrapped in `hsl()`, e.g. `hsl(300,10%,50%)`.");
44
    }
45
46
    public static function malformedHslaColorString(string $string): self
47
    {
48
        return new static("Hsla color string `{$string}` is malformed. An hsla color contains hue, saturation, lightness and alpha values, wrapped in `hsl()`, e.g. `hsl(300,10%,50%,0.25)`.");
49
    }
50
51
    public static function malformedRgbColorString(string $string): self
52
    {
53
        return new static("Rgb color string `{$string}` is malformed. An rgb color contains 3 comma separated values between 0 and 255, wrapped in `rgb()`, e.g. `rgb(0,0,255)`.");
54
    }
55
56
    public static function malformedRgbaColorString(string $string): self
57
    {
58
        return new static("Rgba color string `{$string}` is malformed. An rgba color contains 3 comma separated values between 0 and 255 with an alpha value between 0 and 1, wrapped in `rgba()`, e.g. `rgb(0,0,255,0.5)`.");
59
    }
60
61
    public static function malformedColorString(string $string): self
62
    {
63
        return new static("Color string `{$string}` doesn't match any of the available colors.");
64
    }
65
}
66