Fix for single encoding error, when only the first message was decoded, some logging for Address objects

This commit is contained in:
Deon George
2022-02-13 11:27:12 +11:00
parent f216f42917
commit 12a40a79fb
2 changed files with 14 additions and 5 deletions

View File

@@ -9,6 +9,8 @@ use Illuminate\Support\Arr;
trait EncodeUTF8
{
private array $_encoded = []; // Remember what we've decoded - when calling getAttribute()
private function decode(array $values): void
{
$properties = (new \ReflectionClass($this))->getProperties();
@@ -79,11 +81,9 @@ trait EncodeUTF8
public function getAttribute($key)
{
static $encoded = [];
if (in_array($key,self::cast_utf8) && Arr::get($this->attributes,$key) && (! Arr::get($encoded,$key))) {
if (in_array($key,self::cast_utf8) && Arr::get($this->attributes,$key) && (! Arr::get($this->_encoded,$key))) {
$this->attributes[$key] = utf8_decode($this->attributes[$key]);
$encoded[$key] = TRUE;
$this->_encoded[$key] = TRUE;
}
return parent::getAttribute($key);