diff --git a/src/Ary.php b/src/Ary.php index c912202..0c6a3b8 100644 --- a/src/Ary.php +++ b/src/Ary.php @@ -1,6 +1,6 @@ get($item); } + public function __set($name, $value) + { + $this->offsetSet($name, $value); + } + /** * Get an item from the collection by key. * @@ -109,6 +114,23 @@ class Ary implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable return array_key_exists($key, $this->items); } + /** + * Set the item at a given offset. + * + * @param mixed $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + if (is_null($key)) { + $this->items[] = $value; + } + else { + $this->items[$key] = $value; + } + } + /** * Convert the object into something JSON serializable. * @@ -182,23 +204,6 @@ class Ary implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable return $this->get($key); } - /** - * Set the item at a given offset. - * - * @param mixed $key - * @param mixed $value - * @return void - */ - public function offsetSet($key, $value) - { - if (is_null($key)) { - $this->items[] = $value; - } - else { - $this->items[$key] = $value; - } - } - /** * Unset the item at a given offset. * @@ -267,4 +272,15 @@ class Ary implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable { return (object)$this->all(); } + + +// /** +// * sets a nested ary. +// * @param $key +// * @param $items +// */ +// public function setAry($key, $items) +// { +// $this->items[$key] = new self($items); +// } } \ No newline at end of file