From 7ea44b1157b3645b7655af0143682f3dda0e5970 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 15 Dec 2022 09:11:11 +0100 Subject: [PATCH] wip #5648 --- src/Data.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Data.php b/src/Data.php index 2da2496..1b4ba09 100644 --- a/src/Data.php +++ b/src/Data.php @@ -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()); } } -- 2.39.5