File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,11 @@ class JsonDiff
48
48
49
49
private $ options = 0 ;
50
50
51
+ /**
52
+ * @var array Skip included paths
53
+ */
54
+ private $ skipPaths = [];
55
+
51
56
/**
52
57
* @var mixed Merge patch container
53
58
*/
@@ -88,16 +93,19 @@ class JsonDiff
88
93
* @param mixed $original
89
94
* @param mixed $new
90
95
* @param int $options
96
+ * @param array $skipPaths
91
97
* @throws Exception
92
98
*/
93
- public function __construct ($ original , $ new , $ options = 0 )
99
+ public function __construct ($ original , $ new , $ options = 0 , $ skipPaths = [] )
94
100
{
95
101
if (!($ options & self ::SKIP_JSON_PATCH )) {
96
102
$ this ->jsonPatch = new JsonPatch ();
97
103
}
98
104
99
105
$ this ->options = $ options ;
100
106
107
+ $ this ->skipPaths = $ skipPaths ;
108
+
101
109
if ($ options & self ::JSON_URI_FRAGMENT_ID ) {
102
110
$ this ->path = '# ' ;
103
111
}
@@ -268,7 +276,7 @@ private function process($original, $new)
268
276
(!$ original instanceof \stdClass && !is_array ($ original ))
269
277
|| (!$ new instanceof \stdClass && !is_array ($ new ))
270
278
) {
271
- if ($ original !== $ new ) {
279
+ if ($ original !== $ new && ! in_array ( $ this -> path , $ this -> skipPaths ) ) {
272
280
$ this ->modifiedCnt ++;
273
281
if ($ this ->options & self ::STOP_ON_DIFF ) {
274
282
return null ;
You can’t perform that action at this time.
0 commit comments