From 13b14bff91734bcf3578570d9f464aa3056e55cd Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 25 Oct 2020 16:55:05 +0000 Subject: [PATCH] Return 'null' on empty card --- src/Object/Api/Mastodon/Card.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Object/Api/Mastodon/Card.php b/src/Object/Api/Mastodon/Card.php index 990f6a6bf..46aea3c28 100644 --- a/src/Object/Api/Mastodon/Card.php +++ b/src/Object/Api/Mastodon/Card.php @@ -59,4 +59,18 @@ class Card extends BaseEntity $this->type = $attachment['type'] ?? ''; $this->image = $attachment['image'] ?? ''; } + + /** + * Returns the current entity as an array + * + * @return array + */ + public function toArray() + { + if (empty($this->url)) { + return null; + } + + return parent::toArray(); + } }