| 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 | 10 | public function __construct(Integer $octet) |
|
| 28 | { |
||
| 29 | 10 | $this->original = $octet; |
|
| 30 | 10 | } |
|
| 31 | |||
| 32 | 2 | public static function of(Integer $value): self |
|
| 33 | { |
||
| 34 | 2 | if (!self::definitionSet()->contains($value)) { |
|
| 35 | 2 | throw new OutOfRangeValue($value, self::definitionSet()); |
|
| 36 | } |
||
| 37 | |||
| 38 | return new self($value); |
||
| 39 | } |
||
| 40 | |||
| 41 | 6 | public static function fromStream(Readable $stream): Value |
|
| 42 | { |
||
| 43 | 6 | [, $value] = \unpack('c', (string) $stream->read(1)); |
|
| 44 | |||
| 45 | 6 | return new self(new Integer($value)); |
|
| 46 | } |
||
| 47 | |||
| 48 | 7 | public function original(): Integer |
|
| 49 | { |
||
| 50 | 7 | return $this->original; |
|
| 51 | } |
||
| 52 | |||
| 53 | 11 | public function __toString(): string |
|
| 56 | } |
||
| 57 | |||
| 58 | 2 | public static function definitionSet(): Set |
|
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |