Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
18 | final class SignedShortInteger implements Value |
||
19 | { |
||
20 | private static $definitionSet; |
||
21 | |||
22 | private $value; |
||
23 | private $original; |
||
24 | |||
25 | 11 | public function __construct(Integer $value) |
|
32 | 9 | } |
|
33 | |||
34 | 4 | public static function fromStream(Readable $stream): Value |
|
35 | { |
||
36 | 4 | [, $value] = unpack('s', (string) $stream->read(2)); |
|
37 | |||
38 | 4 | return new self(new Integer($value)); |
|
39 | } |
||
40 | |||
41 | 8 | public function original(): Integer |
|
44 | } |
||
45 | |||
46 | 8 | public function __toString(): string |
|
47 | { |
||
48 | 8 | return $this->value ?? $this->value = pack('s', $this->original->value()); |
|
49 | } |
||
50 | |||
51 | 11 | public static function definitionSet(): Set |
|
56 | ); |
||
57 | } |
||
58 | } |
||
59 |