*/ final class AllResponse implements ApiResponse { /** * @var int */ private $totalCount; /** * @var AllResponseItem[] */ private $items; /** * @param int $totalCount * @param AllResponseItem[] $items */ private function __construct($totalCount, array $items) { $this->totalCount = $totalCount; $this->items = $items; } /** * @param array $data * * @return self */ public static function create(array $data) { $items = []; if (isset($data['items'])) { foreach ($data['items'] as $i) { $items[] = AllResponseItem::create($i); } } if (isset($data['total_count'])) { $count = $data['total_count']; } else { $count = count($items); } return new self($count, $items); } /** * @return int */ public function getTotalCount() { return $this->totalCount; } /** * @return AllResponseItem[] */ public function getItems() { return $this->items; } }