| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 93.75% |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | final class UnsignedOctet implements Value |
||
| 21 | { |
||
| 22 | private static $definitionSet; |
||
| 23 | |||
| 24 | private $value; |
||
| 25 | private $original; |
||
| 26 | |||
| 27 | 141 | public function __construct(Integer $octet) |
|
| 28 | { |
||
| 29 | 141 | if (!self::definitionSet()->contains($octet)) { |
|
| 30 | 3 | throw new OutOfRangeValue($octet, self::definitionSet()); |
|
| 31 | } |
||
| 32 | |||
| 33 | 138 | $this->original = $octet; |
|
| 34 | 138 | } |
|
| 35 | |||
| 36 | 82 | public static function fromStream(Readable $stream): Value |
|
| 37 | { |
||
| 38 | 82 | [, $octet] = unpack('C', (string) $stream->read(1)); |
|
| 39 | |||
| 40 | 82 | return new self(new Integer($octet)); |
|
| 41 | } |
||
| 42 | |||
| 43 | 84 | public function original(): Integer |
|
| 44 | { |
||
| 45 | 84 | return $this->original; |
|
| 46 | } |
||
| 47 | |||
| 48 | 137 | public function __toString(): string |
|
| 51 | } |
||
| 52 | |||
| 53 | 141 | public static function definitionSet(): Set |
|
| 58 | ); |
||
| 59 | } |
||
| 61 |