1: <?php
2: namespace NGS\Converter;
3:
4: require_once(__DIR__.'/ConverterInterface.php');
5: require_once(__DIR__.'/../ByteStream.php');
6:
7: class ByteStreamConverter implements ConverterInterface
8: {
9: public static function toJson($value = null)
10: {
11: return $value === null ? null : (string) $value;
12: }
13:
14: public static function fromJson($value)
15: {
16: if (!is_string($value)) {
17: throw new InvalidArgumentException('Cannot convert JSON value to BigInt. Value is not string');
18: }
19:
20: return new ByteStream(\base64_decode($value));
21: }
22: }
23: