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

SevenBitChannel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
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 50
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get8Bit() 0 3 1
A invert() 0 3 1
A getFloat() 0 3 1
A getPercent() 0 3 1
A get7Bit() 0 3 1
A __construct() 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 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