dgifford / array-access-trait
Trait providing methods to implement array access using a container variable.
v1.1
2016-10-06 14:17 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-05-14 05:10:17 UTC
README
Adds the basic methods for accessing properties of an object using array notation.
For example:
$foo = new Foo;
$foo['bar'] = 'bar';
echo $foo['bar']; // 'bar'
unset( $foo['bar'] );
var_dump( isset($foo['bar']) ); // 'false'
Properties created in this way are stored in a private array called 'container'.
Any class that uses this trait must implement the ArrayAccess interface, see http://php.net/manual/en/class.arrayaccess.php.
For example:
class Foo implements \ArrayAccess
{
}
Changelog
- v1.0 Initial release