Skip to content

Commit 7f73dc8

Browse files
committed
Allow access as Array
1 parent 5016bdf commit 7f73dc8

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/Model.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Class Model
1616
* @package Connect
1717
*/
18-
class Model
18+
class Model implements \ArrayAccess
1919
{
2020
/**
2121
* Required properties, if the object is instantiated without
@@ -298,6 +298,43 @@ public function toJSON($pretty = false)
298298
return json_encode($this->toArray(), $pretty ? JSON_PRETTY_PRINT : null);
299299
}
300300

301+
/**
302+
* @param mixed $offset
303+
* @param mixed $value
304+
*/
305+
public function offsetSet($offset, $value)
306+
{
307+
$this->set($offset, $value);
308+
}
309+
310+
/**
311+
* @param mixed $offset
312+
* @return bool
313+
*/
314+
public function offsetExists($offset)
315+
{
316+
return isset($this->{$offset});
317+
}
318+
319+
/**
320+
* @param mixed $offset
321+
*/
322+
public function offsetUnset($offset)
323+
{
324+
unset($this->{$offset});
325+
}
326+
327+
/**
328+
* @param mixed $offset
329+
* @return mixed|null
330+
*/
331+
public function offsetGet($offset)
332+
{
333+
return isset($this->{$offset})
334+
? $this->get($offset)
335+
: null;
336+
}
337+
301338
/**
302339
* Debug method
303340
* @return array

0 commit comments

Comments
 (0)