PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / google / apiclient / src / Collection.php
ameliabooking / vendor / google / apiclient / src Last commit date
AccessToken 6 months ago AuthHandler 6 months ago Http 6 months ago Service 6 months ago Task 6 months ago Utils 6 months ago Client.php 6 months ago Collection.php 6 months ago Exception.php 6 months ago Model.php 6 months ago Service.php 6 months ago aliases.php 6 months ago
Collection.php
123 lines
1 <?php
2
3 namespace AmeliaVendor\Google;
4
5 /**
6 * Extension to the regular Google\Model that automatically
7 * exposes the items array for iteration, so you can just
8 * iterate over the object rather than a reference inside.
9 */
10 class Collection extends Model implements \Iterator, \Countable
11 {
12 protected $collection_key = 'items';
13
14 /** @return void */
15 #[\ReturnTypeWillChange]
16 public function rewind()
17 {
18 if (
19 isset($this->{$this->collection_key})
20 && is_array($this->{$this->collection_key})
21 ) {
22 reset($this->{$this->collection_key});
23 }
24 }
25
26 /** @return mixed */
27 #[\ReturnTypeWillChange]
28 public function current()
29 {
30 $this->coerceType($this->key());
31 if (is_array($this->{$this->collection_key})) {
32 return current($this->{$this->collection_key});
33 }
34 }
35
36 /** @return mixed */
37 #[\ReturnTypeWillChange]
38 public function key()
39 {
40 if (
41 isset($this->{$this->collection_key})
42 && is_array($this->{$this->collection_key})
43 ) {
44 return key($this->{$this->collection_key});
45 }
46 }
47
48 /** @return mixed */
49 #[\ReturnTypeWillChange]
50 public function next()
51 {
52 return next($this->{$this->collection_key});
53 }
54
55 /** @return bool */
56 #[\ReturnTypeWillChange]
57 public function valid()
58 {
59 $key = $this->key();
60 return $key !== null && $key !== false;
61 }
62
63 /** @return int */
64 #[\ReturnTypeWillChange]
65 public function count()
66 {
67 if (!isset($this->{$this->collection_key})) {
68 return 0;
69 }
70 return count($this->{$this->collection_key});
71 }
72
73 /** @return bool */
74 #[\ReturnTypeWillChange]
75 public function offsetExists($offset)
76 {
77 if (!is_numeric($offset)) {
78 return parent::offsetExists($offset);
79 }
80 return isset($this->{$this->collection_key}[$offset]);
81 }
82
83 /** @return mixed */
84 #[\ReturnTypeWillChange]
85 public function offsetGet($offset)
86 {
87 if (!is_numeric($offset)) {
88 return parent::offsetGet($offset);
89 }
90 $this->coerceType($offset);
91 return $this->{$this->collection_key}[$offset];
92 }
93
94 /** @return void */
95 #[\ReturnTypeWillChange]
96 public function offsetSet($offset, $value)
97 {
98 if (!is_numeric($offset)) {
99 parent::offsetSet($offset, $value);
100 }
101 $this->{$this->collection_key}[$offset] = $value;
102 }
103
104 /** @return void */
105 #[\ReturnTypeWillChange]
106 public function offsetUnset($offset)
107 {
108 if (!is_numeric($offset)) {
109 parent::offsetUnset($offset);
110 }
111 unset($this->{$this->collection_key}[$offset]);
112 }
113
114 private function coerceType($offset)
115 {
116 $keyType = $this->keyType($this->collection_key);
117 if ($keyType && !is_object($this->{$this->collection_key}[$offset])) {
118 $this->{$this->collection_key}[$offset] =
119 new $keyType($this->{$this->collection_key}[$offset]);
120 }
121 }
122 }
123