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.

HSVTransition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A interpolate() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Color\Transition;
6
7
use Artack\Color\Color\Color;
8
use Artack\Color\Color\HSV;
9
use Webmozart\Assert\Assert;
10
11
class HSVTransition implements TransitionInterface
12
{
13 8
    public function interpolate(Color $startColor, Color $endColor, float $value, float $max): Color
14
    {
15
        /* @var HSV $startColor */
16 8
        Assert::isInstanceOf($startColor, HSV::class, sprintf('startColor needs to be an instance of [%s]', HSV::class));
17
18
        /* @var HSV $endColor */
19 8
        Assert::isInstanceOf($endColor, HSV::class, sprintf('endColor needs to be an instance of [%s]', HSV::class));
20
21 8
        $step = $value / $max;
22
23 8
        $hue = $startColor->getHue() + ($endColor->getHue() - $startColor->getHue()) * $step;
24 8
        $saturation = $startColor->getSaturation() + ($endColor->getSaturation() - $startColor->getSaturation()) * $step;
25 8
        $value = $startColor->getValue() + ($endColor->getValue() - $startColor->getValue()) * $step;
26
27 8
        return new HSV((int) round($hue), $saturation, $value);
28
    }
29
30 3
    public function supports(string $fqcn): bool
31
    {
32 3
        return HSV::class === $fqcn;
33
    }
34
}
35