| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | final class SignedShortInteger implements Value |
||
| 16 | { |
||
| 17 | private static $definitionSet; |
||
| 18 | |||
| 19 | private $value; |
||
| 20 | private $original; |
||
| 21 | |||
| 22 | 9 | public function __construct(Integer $value) |
|
| 23 | { |
||
| 24 | 9 | $this->original = $value; |
|
| 25 | 9 | } |
|
| 26 | |||
| 27 | 4 | public static function fromStream(Readable $stream): Value |
|
| 28 | { |
||
| 29 | 4 | [, $value] = unpack('s', (string) $stream->read(2)); |
|
| 30 | |||
| 31 | 4 | return new self(new Integer($value)); |
|
| 32 | } |
||
| 33 | |||
| 34 | 8 | public function original(): Integer |
|
| 37 | } |
||
| 38 | |||
| 39 | 8 | public function __toString(): string |
|
| 40 | { |
||
| 41 | 8 | return $this->value ?? $this->value = pack('s', $this->original->value()); |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | public static function definitionSet(): Set |
|
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |