public static function factory(Client $client, $type = null, $data = []) { switch ($type) { case 'account': return new AccountResponse($data, $client->getOptions()); case 'user': return new UserResponse($data, $client->getOptions()); case 'user-right': return new UserRightResponse($data, $client->getOptions()); default: return new self($data, $client->getOptions()); } }
/** * Load the next page in the collection and populate the current items. * * @return bool * * @throws \Exception */ public function load() { if (!isset($this->links['next'])) { throw new \Exception('No more pages to load.'); } $collection = $this->client->get($this->links['next']); if (!$collection instanceof self) { throw new \Exception('Expected ' . __CLASS__ . ', but got ' . (is_object($collection) ? get_class($collection) : (string) $collection)); } $this->items += $collection->getItems(); return true; }