From a0f7b65275d914f9644b83893d7f38e05182ef7d Mon Sep 17 00:00:00 2001 From: Pavel Date: Mon, 24 Jun 2019 12:18:39 +0300 Subject: [PATCH] Remove duplicated code from ListResponse --- src/Bot/Model/Response/ListResponse.php | 40 +++---------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/Bot/Model/Response/ListResponse.php b/src/Bot/Model/Response/ListResponse.php index d4a8e09..5d7d88f 100644 --- a/src/Bot/Model/Response/ListResponse.php +++ b/src/Bot/Model/Response/ListResponse.php @@ -28,26 +28,18 @@ use RetailCrm\Common\Serializer; */ class ListResponse implements \Iterator, \ArrayAccess, \Countable { + use CommonFields; + /** * @var array */ private $items = []; - /** - * @var array - */ - private $errors = []; - /** * @var int */ private $position = 0; - /** - * @var int $statusCode - */ - private $statusCode; - /** * ListResponse constructor. * @@ -57,10 +49,10 @@ class ListResponse implements \Iterator, \ArrayAccess, \Countable */ public function __construct($responseType, $data, $statusCode) { - $this->statusCode = $statusCode; + $this->setStatusCode($statusCode); if (isset($data['errors'])) { - $this->errors = $data['errors']; + $this->setErrors($data['errors']); } else { foreach ($data as $item) { $this->items[] = @@ -77,14 +69,6 @@ class ListResponse implements \Iterator, \ArrayAccess, \Countable return empty($this->errors); } - /** - * @return array - */ - public function getErrors() - { - return $this->errors; - } - /** * \Countable implementation * @@ -215,20 +199,4 @@ class ListResponse implements \Iterator, \ArrayAccess, \Countable { return isset($this->items[$this->position]); } - - /** - * @return int - */ - public function getStatusCode(): int - { - return $this->statusCode; - } - - /** - * @param int $statusCode - */ - public function setStatusCode(int $statusCode): void - { - $this->statusCode = $statusCode; - } }