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

PercentChannel::getPercent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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