55use GuzzleHttp \Message \ResponseInterface as Response ;
66use Swader \Diffbot \Abstracts \Entity ;
77
8- class EntityIterator implements \Countable, \Iterator
8+ class EntityIterator implements \Countable, \Iterator, \ArrayAccess
99{
1010 /** @var array */
1111 protected $ data ;
@@ -95,4 +95,72 @@ public function __get($name)
9595
9696 return $ entity ->$ name ;
9797 }
98+
99+ /**
100+ * (PHP 5 >= 5.0.0)<br/>
101+ * Whether a offset exists
102+ * @link http://php.net/manual/en/arrayaccess.offsetexists.php
103+ * @param mixed $offset <p>
104+ * An offset to check for.
105+ * </p>
106+ * @return boolean true on success or false on failure.
107+ * </p>
108+ * <p>
109+ * The return value will be casted to boolean if non-boolean was returned.
110+ */
111+ public function offsetExists ($ offset )
112+ {
113+ return (isset ($ this ->data [$ offset ]));
114+ }
115+
116+ /**
117+ * (PHP 5 >= 5.0.0)<br/>
118+ * Offset to retrieve
119+ * @link http://php.net/manual/en/arrayaccess.offsetget.php
120+ * @param mixed $offset <p>
121+ * The offset to retrieve.
122+ * </p>
123+ * @return mixed Can return all value types.
124+ */
125+ public function offsetGet ($ offset )
126+ {
127+ if ($ this ->offsetExists ($ offset )) {
128+ return $ this ->data [$ offset ];
129+ }
130+ }
131+
132+ /**
133+ * (PHP 5 >= 5.0.0)<br/>
134+ * Offset to set
135+ * @link http://php.net/manual/en/arrayaccess.offsetset.php
136+ * @param mixed $offset <p>
137+ * The offset to assign the value to.
138+ * </p>
139+ * @param mixed $value <p>
140+ * The value to set.
141+ * </p>
142+ * @return void
143+ */
144+ public function offsetSet ($ offset , $ value )
145+ {
146+ throw new \BadMethodCallException (
147+ 'Resultset is read only '
148+ );
149+ }
150+
151+ /**
152+ * (PHP 5 >= 5.0.0)<br/>
153+ * Offset to unset
154+ * @link http://php.net/manual/en/arrayaccess.offsetunset.php
155+ * @param mixed $offset <p>
156+ * The offset to unset.
157+ * </p>
158+ * @return void
159+ */
160+ public function offsetUnset ($ offset )
161+ {
162+ if ($ this ->offsetExists ($ offset )) {
163+ unset($ this ->data [$ offset ]);
164+ }
165+ }
98166}
0 commit comments