| @@ 11-28 (lines=18) @@ | ||
| 8 | Exception\OutOfRangeValue |
|
| 9 | }; |
|
| 10 | ||
| 11 | final class UnsignedLongInteger implements Value |
|
| 12 | { |
|
| 13 | private $value; |
|
| 14 | ||
| 15 | public function __construct(int $value) |
|
| 16 | { |
|
| 17 | if ($value < 0 || $value > 4294967295) { |
|
| 18 | throw new OutOfRangeValue($value, 0, 4294967295); |
|
| 19 | } |
|
| 20 | ||
| 21 | $this->value = pack('N', $value); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function __toString(): string |
|
| 25 | { |
|
| 26 | return $this->value; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 11-28 (lines=18) @@ | ||
| 8 | Exception\OutOfRangeValue |
|
| 9 | }; |
|
| 10 | ||
| 11 | final class UnsignedLongLongInteger implements Value |
|
| 12 | { |
|
| 13 | private $value; |
|
| 14 | ||
| 15 | public function __construct(int $value) |
|
| 16 | { |
|
| 17 | if ($value < 0) { |
|
| 18 | throw new OutOfRangeValue($value, 0, PHP_INT_MAX); |
|
| 19 | } |
|
| 20 | ||
| 21 | $this->value = pack('J', $value); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function __toString(): string |
|
| 25 | { |
|
| 26 | return $this->value; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 11-28 (lines=18) @@ | ||
| 8 | Exception\OutOfRangeValue |
|
| 9 | }; |
|
| 10 | ||
| 11 | final class UnsignedOctet implements Value |
|
| 12 | { |
|
| 13 | private $value; |
|
| 14 | ||
| 15 | public function __construct(int $octet) |
|
| 16 | { |
|
| 17 | if ($octet < 0 || $octet > 255) { |
|
| 18 | throw new OutOfRangeValue($octet, 0, 255); |
|
| 19 | } |
|
| 20 | ||
| 21 | $this->value = chr($octet); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function __toString(): string |
|
| 25 | { |
|
| 26 | return $this->value; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 11-28 (lines=18) @@ | ||
| 8 | Exception\OutOfRangeValue |
|
| 9 | }; |
|
| 10 | ||
| 11 | final class UnsignedShortInteger implements Value |
|
| 12 | { |
|
| 13 | private $value; |
|
| 14 | ||
| 15 | public function __construct(int $value) |
|
| 16 | { |
|
| 17 | if ($value < 0 || $value > 65535) { |
|
| 18 | throw new OutOfRangeValue($value, 0, 65535); |
|
| 19 | } |
|
| 20 | ||
| 21 | $this->value = pack('n', $value); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function __toString(): string |
|
| 25 | { |
|
| 26 | return $this->value; |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||