From: Vincent Vanwaelscappel Date: Thu, 15 Dec 2022 08:11:11 +0000 (+0100) Subject: wip #5648 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7ea44b1157b3645b7655af0143682f3dda0e5970;p=cubist_util.git wip #5648 --- 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()); } }