for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace BuildR\Foundation\Object;
use BuildR\Foundation\Object\ArrayObjectInterface;
use \ArrayIterator;
/**
* Common interface for object that can be convertible to array.
*
* BuildR PHP Framework
* @author Zoltán Borsos <[email protected]>
* @package Foundation
* @subpackage Object
* @copyright Copyright 2015, Zoltán Borsos.
* @license https://github.com/Zolli/BuildR/blob/master/LICENSE.md
* @link https://github.com/Zolli/BuildR
*/
class AbstractArrayObject implements ArrayObjectInterface {
* @type array
protected $data = [];
* @inheritDoc
public function toArray() {
return $this->data;
}
public function count() {
return (int) count($this->data);
public function getIterator() {
return new ArrayIterator($this->data);
public function offsetExists($offset) {
return (bool) isset($this->data[$offset]);
public function offsetGet($offset) {
return isset($this->data[$offset]) ? $this->data[$offset] : NULL;
public function offsetSet($offset, $value) {
$this->data[$offset] = $value;
public function offsetUnset($offset) {
if(isset($this->data[$offset])) {
unset($this->data[$offset]);
public function serialize() {
return serialize($this->data);
public function unserialize($serialized) {
$this->data = unserialize($serialized);