From 776fda7653e49c31c70fe4a0a5b861b4b2bb4a23 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 22 Aug 2022 16:33:16 +0200 Subject: [PATCH] wip #5408 --- src/Data.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; } -- 2.39.5