File tree Expand file tree Collapse file tree 3 files changed +31
-26
lines changed
src/Dflydev/DotAccessData Expand file tree Collapse file tree 3 files changed +31
-26
lines changed Original file line number Diff line number Diff line change 22
33/*
44 * This file is a part of dflydev/dot-access-data.
5- *
5+ *
66 * (c) Dragonfly Development Inc.
77 *
88 * For the full copyright and license information, please view the LICENSE
@@ -15,14 +15,14 @@ class Data implements DataInterface
1515{
1616 /**
1717 * Internal representation of data data
18- *
18+ *
1919 * @var array
2020 */
2121 protected $ data ;
2222
2323 /**
2424 * Constructor
25- *
25+ *
2626 * @param array|null $data
2727 */
2828 public function __construct (array $ data = null )
@@ -65,7 +65,7 @@ public function append($key, $value = null)
6565 $ currentValue =& $ currentValue [$ currentKey ];
6666 }
6767
68- if (!isset ($ currentValue [$ endKey ])) {
68+ if (!isset ($ currentValue [$ endKey ])) {
6969 $ currentValue [$ endKey ] = array ();
7070 }
7171 if (!is_array ($ currentValue [$ endKey ])) {
@@ -195,4 +195,4 @@ public function export()
195195 {
196196 return $ this ->data ;
197197 }
198- }
198+ }
Original file line number Diff line number Diff line change 22
33/*
44 * This file is a part of dflydev/dot-access-data.
5- *
5+ *
66 * (c) Dragonfly Development Inc.
77 *
88 * For the full copyright and license information, please view the LICENSE
@@ -15,63 +15,65 @@ interface DataInterface
1515{
1616 /**
1717 * Append a value to a key (assumes key refers to an array value)
18- *
18+ *
1919 * @param string $key
20- * @param mixed $value
20+ * @param mixed $value
2121 */
2222 public function append ($ key , $ value = null );
2323
2424 /**
2525 * Set a value for a key
26- *
26+ *
2727 * @param string $key
28- * @param mixed $value
28+ * @param mixed $value
2929 */
3030 public function set ($ key , $ value = null );
3131
3232 /**
3333 * Remove a key
34- *
34+ *
3535 * @param string $key
3636 */
3737 public function remove ($ key );
3838
3939 /**
4040 * Get the raw value for a key
41- *
41+ *
4242 * @param string $key
43+ *
4344 * @return mixed
4445 */
4546 public function get ($ key );
4647
4748 /**
4849 * Get a data instance for a key
49- *
50+ *
5051 * @param string $key
52+ *
5153 * @return DataInterface
5254 */
5355 public function getData ($ key );
5456
5557 /**
5658 * Import data into existing data
57- *
59+ *
5860 * @param array $data
59- * @param bool $clobber
61+ * @param bool $clobber
6062 */
6163 public function import (array $ data , $ clobber = true );
6264
6365 /**
6466 * Import data from an external data into existing data
65- *
67+ *
6668 * @param DataInterface $data
67- * @param bool $clobber
69+ * @param bool $clobber
6870 */
6971 public function importData (DataInterface $ data , $ clobber = true );
7072
7173 /**
7274 * Export data as raw data
73- *
75+ *
7476 * @return array
7577 */
7678 public function export ();
77- }
79+ }
Original file line number Diff line number Diff line change 22
33/*
44 * This file is a part of dflydev/dot-access-data.
5- *
5+ *
66 * (c) Dragonfly Development Inc.
77 *
88 * For the full copyright and license information, please view the LICENSE
@@ -20,32 +20,35 @@ class Util
2020 * empty arrays will be treated as if they are associative arrays.
2121 *
2222 * @param array $arr
23+ *
2324 * @return boolean
2425 */
25- static public function isAssoc (array $ arr )
26+ public static function isAssoc (array $ arr )
2627 {
2728 return (is_array ($ arr ) && (!count ($ arr ) || count (array_filter (array_keys ($ arr ),'is_string ' )) == count ($ arr )));
2829 }
2930
3031 /**
3132 * Merge contents from one associtative array to another
32- *
33+ *
3334 * @param array $to
3435 * @param array $from
35- * @param bool $clobber
36+ * @param bool $clobber
3637 */
37- static public function mergeAssocArray ($ to , $ from , $ clobber = true )
38+ public static function mergeAssocArray ($ to , $ from , $ clobber = true )
3839 {
3940 if ( is_array ($ from ) ) {
40- foreach ( $ from as $ k => $ v ) {
41+ foreach ($ from as $ k => $ v ) {
4142 if (!isset ($ to [$ k ])) {
4243 $ to [$ k ] = $ v ;
4344 } else {
4445 $ to [$ k ] = self ::mergeAssocArray ($ to [$ k ], $ v , $ clobber );
4546 }
4647 }
48+
4749 return $ to ;
4850 }
51+
4952 return $ clobber ? $ from : $ to ;
5053 }
51- }
54+ }
You can’t perform that action at this time.
0 commit comments