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