From: Vincent Vanwaelscappel Date: Mon, 22 Aug 2022 14:33:16 +0000 (+0200) Subject: wip #5408 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=776fda7653e49c31c70fe4a0a5b861b4b2bb4a23;p=cubist_util.git wip #5408 --- diff --git a/src/Data.php b/src/Data.php index 6907427..51aef23 100644 --- a/src/Data.php +++ b/src/Data.php @@ -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; }