| Total Complexity | 15 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class ResultSet implements Iterator, Countable |
||
| 11 | { |
||
| 12 | protected $array; |
||
| 13 | protected $current = 0; |
||
| 14 | protected $rateLimitRetryAttempts = 5; |
||
| 15 | protected $rateLimitTimeout = 10; |
||
| 16 | protected $reviews; |
||
| 17 | |||
| 18 | public function __construct(Reviews $reviews, array $startingArray) |
||
| 22 | } |
||
| 23 | |||
| 24 | public function current() |
||
| 25 | { |
||
| 26 | return $this->array[$this->current]; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function next() |
||
| 32 | } |
||
| 33 | |||
| 34 | public function key() |
||
| 37 | } |
||
| 38 | |||
| 39 | public function valid() |
||
| 40 | { |
||
| 41 | if (isset($this->array[$this->current])) { |
||
| 42 | return true; |
||
| 43 | } |
||
| 44 | |||
| 45 | $settings = $this->reviews->getSettings(); |
||
| 46 | if ($this->current % $settings['limit'] == 0 && $this->current > 0) { |
||
| 47 | $this->reviews->offset( |
||
| 48 | $settings['limit'] + $settings['offset'] |
||
| 49 | ); |
||
| 50 | |||
| 51 | $this->getMoreResults(); |
||
| 52 | return isset($this->array[$this->current]); |
||
| 53 | } |
||
| 54 | |||
| 55 | return false; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function rewind() |
||
| 59 | { |
||
| 60 | $this->current = 0; |
||
| 61 | } |
||
| 62 | |||
| 63 | public function getArray() |
||
| 66 | } |
||
| 67 | |||
| 68 | public function count() |
||
| 69 | { |
||
| 70 | return count($this->array); |
||
| 71 | } |
||
| 72 | |||
| 73 | protected function getMoreResults() |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 |