Passed
Push — master ( 689ec5...45f08c )
by Sebastian
05:26
created

PercentChannel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 8
c 1
b 0
f 0
dl 0
loc 35
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getFloat() 0 3 1
A get8Bit() 0 3 1
A getPercent() 0 3 1
A invert() 0 3 1
A get7Bit() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils\RGBAColor\ColorChannel;
6
7
use AppUtils\RGBAColor\ColorChannel;
8
use AppUtils\RGBAColor\UnitsConverter;
9
10
class PercentChannel extends ColorChannel
11
{
12
    /**
13
     * @var float
14
     */
15
    private $value;
16
17
    public function __construct(float $value)
18
    {
19
        $this->value = $value;
20
    }
21
22
    public function getFloat() : float
23
    {
24
        return UnitsConverter::percent2Float($this->value);
25
    }
26
27
    public function get8Bit() : int
28
    {
29
        return UnitsConverter::percent2IntEightBit($this->value);
30
    }
31
32
    public function get7Bit() : int
33
    {
34
        return UnitsConverter::percent2IntSevenBit($this->value);
35
    }
36
37
    public function getPercent() : float
38
    {
39
        return $this->value;
40
    }
41
42
    public function invert() : PercentChannel
43
    {
44
        return ColorChannel::Percent(100-$this->value);
45
    }
46
}
47