property-accessor.php

Simple property accessor library
git clone git://git.finwo.net/lib/property-accessor.php
Log | Files | Refs

commit 3e3f42e3dd9f2105271d425424e404f88728bcc2
parent ffb3728b377fb212282b2952dee8b26b7ccbd758
Author: finwo <finwo@pm.me>
Date:   Sun, 17 Apr 2016 02:10:57 +0200

Added array merger

Diffstat:
Msrc/PropertyAccessor.php | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/PropertyAccessor.php b/src/PropertyAccessor.php @@ -223,6 +223,24 @@ class PropertyAccessor return str_replace(' ','',ucwords($output)); } + protected function mergeArrays(&$original, $new) + { + $source = &$original; + + foreach($new as $key => $value) { + if(is_array($value)) { + // nest deeper + if(!isset($source[$key])) { + $source[$key] = array(); + } + $this->mergeArrays($source[$key], $value); + } else { + // overwrite + $source[$key] = $value; + } + } + } + protected function getDebug() { return $this->debug;