Total Complexity | 7 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
17 | final class UnsignedLongInteger implements Value |
||
18 | { |
||
19 | private static $definitionSet; |
||
20 | |||
21 | private $value; |
||
22 | private $original; |
||
23 | |||
24 | 260 | public function __construct(Integer $value) |
|
25 | { |
||
26 | 260 | $this->original = $value; |
|
27 | 260 | } |
|
28 | |||
29 | 134 | public static function of(Integer $value): self |
|
30 | { |
||
31 | 134 | if (!self::definitionSet()->contains($value)) { |
|
32 | 4 | throw new OutOfRangeValue($value, self::definitionSet()); |
|
33 | } |
||
34 | |||
35 | 130 | return new self($value); |
|
36 | } |
||
37 | |||
38 | 152 | public static function fromStream(Readable $stream): Value |
|
39 | { |
||
40 | 152 | [, $value] = \unpack('N', (string) $stream->read(4)); |
|
41 | |||
42 | 152 | return new self(new Integer($value)); |
|
43 | } |
||
44 | |||
45 | 136 | public function original(): Integer |
|
46 | { |
||
47 | 136 | return $this->original; |
|
48 | } |
||
49 | |||
50 | 258 | public function __toString(): string |
|
53 | } |
||
54 | |||
55 | 134 | public static function definitionSet(): Set |
|
60 | ); |
||
61 | } |
||
62 | } |
||
63 |