]> _ Git - cubist_util.git/commitdiff
wip #5648
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 15 Dec 2022 08:11:11 +0000 (09:11 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 15 Dec 2022 08:11:11 +0000 (09:11 +0100)
src/Data.php

index 2da2496b772a12ed1315ad079f633876cc6a5d2e..1b4ba09ca8455f780d1588c57a75d4005e860a5a 100644 (file)
@@ -36,6 +36,14 @@ class Data implements \ArrayAccess
         Arr::set($this->_data, $this->_offset($offset), $this->_fixValue($value));
     }
 
+    public function push($offset, $value)
+    {
+        $offset = self::square_brackets_to_dots($offset);
+        $newValue = $this->get($offset, []);
+        $newValue[] = $value;
+        Arr::set($this->_data, $this->_offset($offset), $newValue);
+    }
+
     public function setRaw($key, $value)
     {
         $this->_data[$key] = $value;
@@ -234,7 +242,8 @@ class Data implements \ArrayAccess
     /**
      * @return false|string
      */
-    public function asJSON(){
+    public function asJSON()
+    {
         return json_encode($this->getRawData());
     }
 }