Fix casting on compressed attributes when value is NULL, reduce some BINKP debugging messages

This commit is contained in:
Deon George
2022-11-05 00:06:47 +11:00
parent 9721db185b
commit c7187dbb0e
2 changed files with 22 additions and 15 deletions

View File

@@ -10,15 +10,15 @@ class CompressedString implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return string
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return string|null
*/
public function get($model, string $key, $value, array $attributes): string
public function get($model,string $key,$value,array $attributes): ?string
{
return zstd_uncompress(base64_decode($value));
return $value ? zstd_uncompress(base64_decode($value)) : NULL;
}
/**
@@ -30,7 +30,7 @@ class CompressedString implements CastsAttributes
* @param array $attributes
* @return string|null
*/
public function set($model, string $key, $value, array $attributes): ?string
public function set($model,string $key,$value,array $attributes): ?string
{
return $value ? base64_encode(zstd_compress($value)) : NULL;
}