]> _ Git - cubist_util.git/commitdiff
wip #5408
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 14:33:16 +0000 (16:33 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 14:33:16 +0000 (16:33 +0200)
src/Data.php

index 69074271c50c1be1efa00fa563f0316f99c4039e..51aef231e45d24683cb07bdcaf34dd9ea2d598c1 100644 (file)
@@ -28,10 +28,17 @@ class Data implements \ArrayAccess
      */
     public function set($offset, $value)
     {
-        $offset = square_brackets_to_dots($offset);
+        $offset = self::square_brackets_to_dots($offset);
         Arr::set($this->_data, $this->_offset($offset), $this->_fixValue($value));
     }
 
+    protected static function square_brackets_to_dots($string)
+    {
+        $string = str_replace(['[', ']'], ['.', ''], $string);
+
+        return $string;
+    }
+
     protected function _fixValue($value)
     {
         if (!is_array($value)) {
@@ -45,7 +52,7 @@ class Data implements \ArrayAccess
         $dot = Arr::dot($value);
         $res = [];
         foreach ($dot as $k => $v) {
-            Arr::set($res, $this->_offset(square_brackets_to_dots($k)), $v);
+            Arr::set($res, $this->_offset(self::square_brackets_to_dots($k)), $v);
         }
         return $res;
     }