Total Complexity | 9 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | class SevenBitChannel extends ColorChannel |
||
25 | { |
||
26 | public const VALUE_MIN = 0; |
||
27 | public const VALUE_MAX = 127; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | private int $value; |
||
33 | |||
34 | /** |
||
35 | * @param int $value 0-127 |
||
36 | */ |
||
37 | public function __construct(int $value) |
||
38 | { |
||
39 | if($value < self::VALUE_MIN) { $value = self::VALUE_MIN; } |
||
40 | if($value > self::VALUE_MAX) { $value = self::VALUE_MAX; } |
||
41 | |||
42 | $this->value = $value; |
||
43 | } |
||
44 | |||
45 | public function getValue() : int |
||
46 | { |
||
47 | return $this->value; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return int 0-255 |
||
52 | */ |
||
53 | public function get8Bit() : int |
||
54 | { |
||
55 | return UnitsConverter::intSevenBit2IntEightBit($this->value); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return int 0-127 |
||
60 | */ |
||
61 | public function get7Bit() : int |
||
62 | { |
||
63 | return $this->value; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return float 0-1 |
||
68 | */ |
||
69 | public function getAlpha() : float |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return float 0-100 |
||
76 | */ |
||
77 | public function getPercent() : float |
||
78 | { |
||
79 | return UnitsConverter::intSevenBit2Percent($this->value); |
||
80 | } |
||
81 | |||
82 | public function invert() : SevenBitChannel |
||
85 | } |
||
86 | } |
||
87 |