Skip to content

Instantly share code, notes, and snippets.

@pmjones
Created December 20, 2013 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmjones/8061259 to your computer and use it in GitHub Desktop.
Save pmjones/8061259 to your computer and use it in GitHub Desktop.
<?php
namespace foo\bar;
use Aura\Marshal\Entity\MagicArrayAccessTrait;
use ArrayAccess;
class ArrayAccessEntityExample impelements ArrayAccess
{
use MagicArrayAccessTrait;
protected $entity_data;
public function offsetExists($key)
{
return array_key_exists($key, $this->entity_data);
}
public function offsetGet($key)
{
return $this->entity_data[$key];
}
public function offsetSet($key, $val)
{
$this->entity_data[$key] = $val;
}
public function offsetUnset($key)
{
unset($this->entity_data[$key]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment