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
*/
@@ -85,16 +90,19 @@ class JsonDiff
85
90
* @param mixed $original
86
91
* @param mixed $new
87
92
* @param int $options
93
+ * @param array $skipPaths
88
94
* @throws Exception
89
95
*/
90
- public function __construct ($ original , $ new , $ options = 0 )
96
+ public function __construct ($ original , $ new , $ options = 0 , $ skipPaths = [] )
91
97
{
92
98
if (!($ options & self ::SKIP_JSON_PATCH )) {
93
99
$ this ->jsonPatch = new JsonPatch ();
94
100
}
95
101
96
102
$ this ->options = $ options ;
97
103
104
+ $ this ->skipPaths = $ skipPaths ;
105
+
98
106
if ($ options & self ::JSON_URI_FRAGMENT_ID ) {
99
107
$ this ->path = '# ' ;
100
108
}
@@ -265,7 +273,7 @@ private function process($original, $new)
265
273
(!$ original instanceof \stdClass && !is_array ($ original ))
266
274
|| (!$ new instanceof \stdClass && !is_array ($ new ))
267
275
) {
268
- if ($ original !== $ new ) {
276
+ if ($ original !== $ new && ! in_array ( $ this -> path , $ this -> skipPaths ) ) {
269
277
$ this ->modifiedCnt ++;
270
278
if ($ this ->options & self ::STOP_ON_DIFF ) {
271
279
return null ;
You can’t perform that action at this time.
0 commit comments