From 22b3d7207a93994c20c2b0cccb2f44e911b4218b Mon Sep 17 00:00:00 2001 From: Daniel de Wit Date: Thu, 1 Nov 2018 10:14:36 +0100 Subject: [PATCH] Php 7.2 support: Cast to array when counting Fixes #5 --- src/Encoder/Transformers/ModelTransformer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Encoder/Transformers/ModelTransformer.php b/src/Encoder/Transformers/ModelTransformer.php index 7490520..03ad503 100644 --- a/src/Encoder/Transformers/ModelTransformer.php +++ b/src/Encoder/Transformers/ModelTransformer.php @@ -42,15 +42,15 @@ public function transform($model) Key::META => $this->serializeMetaData($resource), ]; - if ( ! count($data[ Key::ATTRIBUTES ])) { + if ( ! count((array) $data[ Key::ATTRIBUTES ])) { unset($data[ Key::ATTRIBUTES ]); } - if ( ! count($data[ Key::RELATIONSHIPS ])) { + if ( ! count((array) $data[ Key::RELATIONSHIPS ])) { unset($data[ Key::RELATIONSHIPS ]); } - if ( ! count($data[ Key::META ])) { + if ( ! count((array) $data[ Key::META ])) { unset($data[ Key::META ]); }