1 | <?php |
||
10 | trait StorageConverterTrait |
||
11 | { |
||
12 | /** |
||
13 | * Converts the flat key/value from the storage engine |
||
14 | * to a heirachy structure based on the key sytax |
||
15 | * |
||
16 | * @param array $data |
||
17 | * @return array |
||
18 | */ |
||
19 | private function dataDecode($data) |
||
33 | |||
34 | /** |
||
35 | * unpack the keys that are structured for arrays so that they no |
||
36 | * longer have the [] syntax at the end. Rather they're now a proper |
||
37 | * array. |
||
38 | * |
||
39 | * @param array $data [description] |
||
40 | * @return array |
||
41 | */ |
||
42 | private function unpackArray($data) |
||
57 | |||
58 | /** |
||
59 | * Flatten a multi-dimensional array into a linear key/value list |
||
60 | * |
||
61 | * @param array $data |
||
62 | * @param string|null $prefix |
||
63 | * @return array |
||
64 | */ |
||
65 | private function dataEncode($data, $prefix = null) |
||
80 | |||
81 | /** |
||
82 | * Encode the array of values against the provided key |
||
83 | * |
||
84 | * @param string $key |
||
85 | * @param array $value either an associative or keyed array |
||
86 | * @param string|null $prefix |
||
87 | * @return array |
||
88 | */ |
||
89 | private function encodeArray($key, array $value, $prefix = null) |
||
100 | } |
||
101 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: