| Total Complexity | 6 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | class Resultset |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Connection |
||
| 14 | */ |
||
| 15 | protected $connection; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $url; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $class; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var array |
||
| 29 | */ |
||
| 30 | protected $params; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Resultset constructor. |
||
| 34 | * |
||
| 35 | * @param Connection $connection |
||
| 36 | * @param string $url |
||
| 37 | * @param string $class |
||
| 38 | * @param array $params |
||
| 39 | */ |
||
| 40 | public function __construct(Connection $connection, $url, $class, array $params) |
||
| 41 | { |
||
| 42 | $this->connection = $connection; |
||
| 43 | $this->url = $url; |
||
| 44 | $this->class = $class; |
||
| 45 | $this->params = $params; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | public function next() |
||
| 52 | { |
||
| 53 | $result = $this->connection->get($this->url, $this->params); |
||
| 54 | $this->url = $this->connection->nextUrl; |
||
| 55 | $this->params = []; |
||
| 56 | |||
| 57 | return $this->collectionFromResult($result); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function hasMore() |
||
| 64 | { |
||
| 65 | return $this->url !== null; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param array $result |
||
| 70 | * |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | protected function collectionFromResult($result) |
||
| 89 | } |
||
| 90 | } |
||
| 91 |