1 | <?php |
||
14 | final class Pointer |
||
15 | { |
||
16 | /** |
||
17 | * @var object|array |
||
18 | */ |
||
19 | private $json; |
||
20 | |||
21 | /** |
||
22 | * @param object|array $json |
||
23 | */ |
||
24 | 90 | public function __construct(&$json) |
|
28 | |||
29 | /** |
||
30 | * @param string $pointer |
||
31 | * |
||
32 | * @return mixed |
||
33 | * |
||
34 | * @throws InvalidPointerException |
||
35 | */ |
||
36 | 58 | public function get($pointer) |
|
46 | |||
47 | /** |
||
48 | * @param string $pointer |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | 54 | public function has($pointer) |
|
56 | |||
57 | /** |
||
58 | * @param string $pointer |
||
59 | * @param mixed $data |
||
60 | * |
||
61 | * @return void |
||
62 | * |
||
63 | * @throws InvalidPointerException |
||
64 | * @throws \InvalidArgumentException |
||
65 | * |
||
66 | */ |
||
67 | 58 | public function set($pointer, $data) |
|
89 | |||
90 | /** |
||
91 | * @param string $pointer |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | 12 | public function remove($pointer) |
|
113 | |||
114 | /** |
||
115 | * @param array $pointer |
||
116 | * |
||
117 | * @return mixed |
||
118 | */ |
||
119 | 64 | private function &getTarget(array $pointer) |
|
133 | |||
134 | /** |
||
135 | * Returns the value referenced by the pointer or a NonExistentValue if the value does not exist. |
||
136 | * |
||
137 | * @param string $pointer The pointer |
||
138 | * |
||
139 | * @return mixed |
||
140 | */ |
||
141 | 68 | private function traverse($pointer) |
|
173 | |||
174 | /** |
||
175 | * Parses a JSON Pointer as defined in the specification. |
||
176 | * @see https://tools.ietf.org/html/rfc6901#section-4 |
||
177 | * |
||
178 | * @param string $pointer |
||
179 | * |
||
180 | * @return array |
||
181 | * |
||
182 | * @throws InvalidPointerException |
||
183 | */ |
||
184 | 86 | private function parse($pointer) |
|
207 | } |
||
208 |