| Total Complexity | 9 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 80% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | abstract class BinaryHandle implements Serializable |
||
| 11 | { |
||
| 12 | use SerializableTrait; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $raw; |
||
| 18 | |||
| 19 | 29 | protected function __construct(string $rawBytes) |
|
| 20 | { |
||
| 21 | 29 | $this->raw = $rawBytes; |
|
| 22 | 29 | } |
|
| 23 | |||
| 24 | 11 | public function toString(): string |
|
| 25 | { |
||
| 26 | 11 | return Base64UrlEncoding::encode($this->raw); |
|
| 27 | } |
||
| 28 | |||
| 29 | 8 | public function toBinary(): string |
|
| 32 | } |
||
| 33 | |||
| 34 | 10 | public function toHex(): string |
|
| 35 | { |
||
| 36 | 10 | return bin2hex($this->raw); |
|
| 37 | } |
||
| 38 | |||
| 39 | 12 | public function toBuffer(): ByteBuffer |
|
| 40 | { |
||
| 41 | 12 | return new ByteBuffer($this->raw); |
|
| 42 | } |
||
| 43 | |||
| 44 | 25 | protected static function convertHex(string $hex): string |
|
| 51 | } |
||
| 52 | |||
| 53 | public function __serialize(): array |
||
| 54 | { |
||
| 55 | return [ |
||
| 56 | 'raw' => $this->raw, |
||
| 57 | ]; |
||
| 58 | } |
||
| 59 | |||
| 60 | public function __unserialize(array $data): void |
||
| 63 | } |
||
| 64 | } |
||
| 65 |