diff --git a/demo/slice.php b/demo/slice.php index 1dc3d06..303f6d1 100644 --- a/demo/slice.php +++ b/demo/slice.php @@ -2,8 +2,7 @@ include_once dirname(__DIR__) . '/vendor/autoload.php'; -$builder = new \Deimos\Builder\Builder(); -$helper = new \Deimos\Helper\Helper($builder); +$helper = new \Deimos\Helper\Helper(); $slice = new \Deimos\Slice\Slice($helper, [ 'dir' => [ diff --git a/src/Slice/Slice.php b/src/Slice/Slice.php index 6e05b86..ff82abd 100644 --- a/src/Slice/Slice.php +++ b/src/Slice/Slice.php @@ -94,11 +94,7 @@ public function setData(array $storage) */ public function getData($path, $default = null) { - return $this->helper->arr()->get( - $this->storage, - $path, - $default - ); + return $this->helper->arr()->get($this->storage, $path, $default); } /** @@ -213,20 +209,11 @@ public function offsetSet($offset, $value) if (null === $offset) { $this->storage[] = $value; - } - else - { - $path = $this->helper->arr()->keys($offset); - $last = array_pop($path); - $row = &$this->storage; - - foreach ($path as $iterator) - { - $row = &$row[$iterator]; - } - $row[$last] = $value; + return; } + + $this->helper->arr()->set($this->storage, $offset, $value); } /** @@ -234,16 +221,7 @@ public function offsetSet($offset, $value) */ public function offsetUnset($offset) { - $path = $this->helper->arr()->keys($offset); - $last = array_pop($path); - $row = &$this->storage; - - foreach ($path as $iterator) - { - $row = &$row[$iterator]; - } - - unset($row[$last]); + $this->helper->arr()->remove($this->storage, $offset); } /**