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

SevenBitChannel::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 SevenBitChannel extends ColorChannel
11
{
12
    /**
13
     * @var int
14
     */
15
    private $value;
16
17
    /**
18
     * @param int $value 0-127
19
     */
20
    public function __construct(int $value)
21
    {
22
        $this->value = $value;
23
    }
24
25
    /**
26
     * @return int 0-255
27
     */
28
    public function get8Bit() : int
29
    {
30
        return UnitsConverter::intSevenBit2IntEightBit($this->value);
31
    }
32
33
    /**
34
     * @return int 0-127
35
     */
36
    public function get7Bit() : int
37
    {
38
        return $this->value;
39
    }
40
41
    /**
42
     * @return float 0-1
43
     */
44
    public function getFloat() : float
45
    {
46
        return UnitsConverter::intSevenBit2Float($this->value);
47
    }
48
49
    /**
50
     * @return float 0-100
51
     */
52
    public function getPercent() : float
53
    {
54
        return UnitsConverter::intSevenBit2Percent($this->value);
55
    }
56
57
    public function invert() : SevenBitChannel
58
    {
59
        return ColorChannel::SevenBit(127-$this->value);
60
    }
61
}
62