Total Complexity | 7 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
20 | final class UnsignedOctet implements Value |
||
21 | { |
||
22 | private static $definitionSet; |
||
23 | |||
24 | private $value; |
||
25 | private $original; |
||
26 | |||
27 | 272 | public function __construct(Integer $octet) |
|
28 | { |
||
29 | 272 | $this->original = $octet; |
|
30 | 272 | } |
|
31 | |||
32 | 144 | public static function of(Integer $octet): self |
|
33 | { |
||
34 | 144 | if (!self::definitionSet()->contains($octet)) { |
|
35 | 10 | throw new OutOfRangeValue($octet, self::definitionSet()); |
|
36 | } |
||
37 | |||
38 | 134 | return new self($octet); |
|
39 | } |
||
40 | |||
41 | 164 | public static function fromStream(Readable $stream): Value |
|
42 | { |
||
43 | 164 | [, $octet] = \unpack('C', (string) $stream->read(1)); |
|
44 | |||
45 | 164 | return new self(new Integer($octet)); |
|
46 | } |
||
47 | |||
48 | 168 | public function original(): Integer |
|
49 | { |
||
50 | 168 | return $this->original; |
|
51 | } |
||
52 | |||
53 | 270 | public function __toString(): string |
|
56 | } |
||
57 | |||
58 | 144 | public static function definitionSet(): Set |
|
59 | { |
||
63 | ); |
||
64 | } |
||
66 |