diff --git a/src/Driver/IgBinary.php b/src/Driver/IgBinary.php index 800130a..36f78d1 100644 --- a/src/Driver/IgBinary.php +++ b/src/Driver/IgBinary.php @@ -7,6 +7,8 @@ final class IgBinary implements Driver { + private const NULL = "\x00"; + /** * @var array */ @@ -15,6 +17,9 @@ final class IgBinary implements Driver public static function encode($value): string { + if ($value === null) { + $value = self::NULL; + } $result = igbinary_serialize($value); if ($result === null) { $error = error_get_last(); @@ -38,13 +43,15 @@ public static function decode(string $value) } throw new InvalidStateException($error['message']); + } elseif ($data === self::NULL) { + return null; } return $data; } - private static function serializationCheckIgbinary(string $value): bool + public static function serializationCheckIgbinary(string $value): bool { return in_array(mb_substr($value, 0, 4), self::$haystack, true); }