File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,11 @@ class JsonDiff
4848
4949 private $ options = 0 ;
5050
51+ /**
52+ * @var array Skip included paths
53+ */
54+ private $ skipPaths = [];
55+
5156 /**
5257 * @var mixed Merge patch container
5358 */
@@ -88,16 +93,19 @@ class JsonDiff
8893 * @param mixed $original
8994 * @param mixed $new
9095 * @param int $options
96+ * @param array $skipPaths
9197 * @throws Exception
9298 */
93- public function __construct ($ original , $ new , $ options = 0 )
99+ public function __construct ($ original , $ new , $ options = 0 , $ skipPaths = [] )
94100 {
95101 if (!($ options & self ::SKIP_JSON_PATCH )) {
96102 $ this ->jsonPatch = new JsonPatch ();
97103 }
98104
99105 $ this ->options = $ options ;
100106
107+ $ this ->skipPaths = $ skipPaths ;
108+
101109 if ($ options & self ::JSON_URI_FRAGMENT_ID ) {
102110 $ this ->path = '# ' ;
103111 }
@@ -268,7 +276,7 @@ private function process($original, $new)
268276 (!$ original instanceof \stdClass && !is_array ($ original ))
269277 || (!$ new instanceof \stdClass && !is_array ($ new ))
270278 ) {
271- if ($ original !== $ new ) {
279+ if ($ original !== $ new && ! in_array ( $ this -> path , $ this -> skipPaths ) ) {
272280 $ this ->modifiedCnt ++;
273281 if ($ this ->options & self ::STOP_ON_DIFF ) {
274282 return null ;
You can’t perform that action at this time.
0 commit comments