From 80fd5609d5b3b75a028dc48e277c61729adceb99 Mon Sep 17 00:00:00 2001 From: Martynas Sudintas <martynas12@gmail.com> Date: Mon, 4 Jun 2018 08:47:30 +0300 Subject: [PATCH] serializer in search is now static (#268) --- src/Search.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Search.php b/src/Search.php index 4a4f686..c2edcca 100644 --- a/src/Search.php +++ b/src/Search.php @@ -155,7 +155,7 @@ class Search /** * @var OrderedSerializer */ - private $serializer; + private static $serializer; /** * @var SearchEndpointInterface[] @@ -167,12 +167,14 @@ class Search */ public function __construct() { - $this->serializer = new OrderedSerializer( - [ - new CustomReferencedNormalizer(), - new CustomNormalizer(), - ] - ); + if (static::$serializer === null) { + static::$serializer = new OrderedSerializer( + [ + new CustomReferencedNormalizer(), + new CustomNormalizer(), + ] + ); + } } /** @@ -698,7 +700,7 @@ class Search */ public function toArray() { - $output = array_filter($this->serializer->normalize($this->endpoints)); + $output = array_filter(static::$serializer->normalize($this->endpoints)); $params = [ 'from' => 'from', -- GitLab