1 | <?php namespace Knot\Dict; |
||
5 | trait PathOperationsTrait { |
||
6 | |||
7 | /** |
||
8 | * For parsing array path. |
||
9 | */ |
||
10 | public static $ARRAY_PATH_DELIMITER = "."; |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $path = ''; |
||
16 | |||
17 | |||
18 | abstract public function childParent(); |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @param null $add |
||
23 | * |
||
24 | * @return null|string |
||
25 | */ |
||
26 | public function path($add = null) |
||
30 | |||
31 | |||
32 | /** |
||
33 | * @param $path |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | public static function pathParser($path) |
||
41 | |||
42 | |||
43 | /** |
||
44 | * @param array $path |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | public static function pathCombiner(array $path) |
||
52 | |||
53 | |||
54 | /** |
||
55 | * @param $path |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function isPath($path) |
||
72 | |||
73 | |||
74 | /** |
||
75 | * @param $path |
||
76 | * |
||
77 | * @return array|ChildDict|Mixed |
||
78 | * @throws WrongArrayPathException |
||
79 | */ |
||
80 | public function get($path) |
||
117 | |||
118 | |||
119 | /** |
||
120 | * For Get path without parsing default return to data. |
||
121 | * |
||
122 | * @param $path |
||
123 | * |
||
124 | * @return Mixed |
||
125 | * @throws WrongArrayPathException |
||
126 | */ |
||
127 | public function getOnly($path) |
||
150 | |||
151 | |||
152 | /** |
||
153 | * @param $rawPath |
||
154 | * @param $value |
||
155 | * |
||
156 | * @return Mixed|\Knot\Dict\ChildDict |
||
157 | */ |
||
158 | public function set($rawPath, $value) |
||
184 | |||
185 | |||
186 | /** |
||
187 | * @param $rawPath |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function del($rawPath) |
||
217 | |||
218 | |||
219 | protected function value($value, array $arguments = [ ]) |
||
223 | } |
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: