Google_Collection

Extension to the regular Google_Model that automatically exposes the items array for iteration, so you can just iterate over the object rather than a reference inside.

Defined (1)

The class is defined in the following location(s).

/vendor/google/apiclient/src/Google/Collection.php  
  1. class Google_Collection extends Google_Model implements Iterator, Countable 
  2. protected $collection_key = 'items'; 
  3.  
  4. public function rewind() 
  5. if (isset($this->modelData[$this->collection_key]) 
  6. && is_array($this->modelData[$this->collection_key])) { 
  7. reset($this->modelData[$this->collection_key]); 
  8.  
  9. public function current() 
  10. $this->coerceType($this->key()); 
  11. if (is_array($this->modelData[$this->collection_key])) { 
  12. return current($this->modelData[$this->collection_key]); 
  13.  
  14. public function key() 
  15. if (isset($this->modelData[$this->collection_key]) 
  16. && is_array($this->modelData[$this->collection_key])) { 
  17. return key($this->modelData[$this->collection_key]); 
  18.  
  19. public function next() 
  20. return next($this->modelData[$this->collection_key]); 
  21.  
  22. public function valid() 
  23. $key = $this->key(); 
  24. return $key !== null && $key !== false; 
  25.  
  26. public function count() 
  27. if (!isset($this->modelData[$this->collection_key])) { 
  28. return 0; 
  29. return count($this->modelData[$this->collection_key]); 
  30.  
  31. public function offsetExists($offset) 
  32. if (!is_numeric($offset)) { 
  33. return parent::offsetExists($offset); 
  34. return isset($this->modelData[$this->collection_key][$offset]); 
  35.  
  36. public function offsetGet($offset) 
  37. if (!is_numeric($offset)) { 
  38. return parent::offsetGet($offset); 
  39. $this->coerceType($offset); 
  40. return $this->modelData[$this->collection_key][$offset]; 
  41.  
  42. public function offsetSet($offset, $value) 
  43. if (!is_numeric($offset)) { 
  44. return parent::offsetSet($offset, $value); 
  45. $this->modelData[$this->collection_key][$offset] = $value; 
  46.  
  47. public function offsetUnset($offset) 
  48. if (!is_numeric($offset)) { 
  49. return parent::offsetUnset($offset); 
  50. unset($this->modelData[$this->collection_key][$offset]); 
  51.  
  52. private function coerceType($offset) 
  53. $typeKey = $this->keyType($this->collection_key); 
  54. if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) { 
  55. $type = $this->$typeKey; 
  56. $this->modelData[$this->collection_key][$offset] = 
  57. new $type($this->modelData[$this->collection_key][$offset]);