1 | <?php |
||
21 | class JsonPatch |
||
22 | { |
||
23 | /** |
||
24 | * Action are based on http://jsonpatch.com/ description |
||
25 | * |
||
26 | */ |
||
27 | const ACTION_ADD = 'add'; |
||
28 | const ACTION_REMOVE = 'remove'; |
||
29 | const ACTION_REPLACE = 'replace'; |
||
30 | const ACTION_COPY = 'copy'; |
||
31 | const ACTION_MOVE = 'move'; |
||
32 | const ACTION_TEST = 'test'; |
||
33 | |||
34 | /** |
||
35 | * @param $path |
||
36 | * @param $action |
||
37 | * @param array|string|boolean $value |
||
38 | * @param $append |
||
39 | * @return array |
||
40 | */ |
||
41 | 164 | public function generate($path, $action, $value = false, $append = false) |
|
49 | |||
50 | /** |
||
51 | * @param $path |
||
52 | * @param $items |
||
53 | * @param bool|false $append |
||
54 | * @return array |
||
55 | */ |
||
56 | 116 | public function generateArrayAdd($path, $items, $append = false) |
|
76 | |||
77 | /** |
||
78 | * @author LAHAXE Arnaud |
||
79 | * |
||
80 | * @param \Generator $patchs |
||
81 | * @param string $targetDocument |
||
82 | * |
||
83 | * @return mixed |
||
84 | */ |
||
85 | 24 | public function compile($patchs, $targetDocument = '{}') |
|
100 | } |
||
101 |