diff --git a/src/Record/Encoded.php b/src/Record/Encoded.php index 3276cde..5257d50 100644 --- a/src/Record/Encoded.php +++ b/src/Record/Encoded.php @@ -121,7 +121,7 @@ public function toArray(): array $result = parent::toArray(); foreach ($result as $key => $value) { - if ($this->isEncodedColumn($key)) { + if (($this->isEncodedColumn($key)) && ($value !== null)) { $result[$key] = $this->decodeValue($key, $value); } } @@ -258,7 +258,7 @@ public function encode(array $columns): array public function decode(array $columns): array { foreach ($columns as $key => $value) { - if ($this->isEncodedColumn($key)) { + if (($this->isEncodedColumn($key)) && ($value !== null)) { $columns[$key] = $this->decodeValue($key, $value); } } @@ -305,7 +305,7 @@ public function __get(string $name): mixed { $value = parent::__get($name); - if ($this->isEncodedColumn($name)) { + if (($this->isEncodedColumn($name)) && ($value !== null)) { $value = $this->decodeValue($name, $value); }