2222 JsonPointerHandlerInterface
2323};
2424use blancks \JsonPatch \operations \{
25- PatchOperationInterface ,
25+ handlers \ PatchOperationHandlerInterface ,
2626 PatchValidationTrait ,
2727 handlers \AddHandler ,
2828 handlers \CopyHandler ,
@@ -48,9 +48,9 @@ final class FastJsonPatch implements JsonHandlerAwareInterface, JsonPointerHandl
4848 private mixed $ document ;
4949
5050 /**
51- * @var array<string, PatchOperationInterface > registered classes for handling patch operations
51+ * @var array<string, PatchOperationHandlerInterface > registered classes for handling patch operations
5252 */
53- private array $ operations = [];
53+ private array $ operationHandlers = [];
5454
5555 /**
5656 * Creates a FastJsonPatch instance from a json string document
@@ -91,21 +91,21 @@ public function __construct(
9191
9292 $ this ->setJsonPointerHandler ($ JsonPointerHandler );
9393 $ this ->setJsonHandler ($ JsonHandler );
94- $ this ->registerOperation (new AddHandler );
95- $ this ->registerOperation (new CopyHandler );
96- $ this ->registerOperation (new MoveHandler );
97- $ this ->registerOperation (new RemoveHandler );
98- $ this ->registerOperation (new ReplaceHandler );
99- $ this ->registerOperation (new TestHandler );
94+ $ this ->registerOperationHandler (new AddHandler );
95+ $ this ->registerOperationHandler (new CopyHandler );
96+ $ this ->registerOperationHandler (new MoveHandler );
97+ $ this ->registerOperationHandler (new RemoveHandler );
98+ $ this ->registerOperationHandler (new ReplaceHandler );
99+ $ this ->registerOperationHandler (new TestHandler );
100100 }
101101
102102 /**
103103 * Allows to register a class that will be responsible to handle a specific patch operation.
104104 * You can replace a handler class for a given operation or register handlers for custom patch operations
105- * @param PatchOperationInterface $PatchOperation
105+ * @param PatchOperationHandlerInterface $PatchOperation
106106 * @return void
107107 */
108- public function registerOperation ( PatchOperationInterface $ PatchOperation ): void
108+ public function registerOperationHandler ( PatchOperationHandlerInterface $ PatchOperation ): void
109109 {
110110 if ($ PatchOperation instanceof JsonHandlerAwareInterface) {
111111 $ PatchOperation ->setJsonHandler ($ this ->JsonHandler );
@@ -115,7 +115,7 @@ public function registerOperation(PatchOperationInterface $PatchOperation): void
115115 $ PatchOperation ->setJsonPointerHandler ($ this ->JsonPointerHandler );
116116 }
117117
118- $ this ->operations [$ PatchOperation ->getOperation ()] = $ PatchOperation ;
118+ $ this ->operationHandlers [$ PatchOperation ->getOperation ()] = $ PatchOperation ;
119119 }
120120
121121 /**
@@ -132,10 +132,10 @@ public function apply(string $patch): void
132132 $ document = &$ this ->document ;
133133
134134 foreach ($ this ->patchIterator ($ patch ) as $ op => $ p ) {
135- if (!isset ($ this ->operations [$ op ])) {
135+ if (!isset ($ this ->operationHandlers [$ op ])) {
136136 throw new InvalidPatchOperationException (sprintf ('Unknown operation "%s" ' , $ op ));
137137 }
138- $ Operation = $ this ->operations [$ op ];
138+ $ Operation = $ this ->operationHandlers [$ op ];
139139 $ Operation ->validate ($ p );
140140 $ Operation ->apply ($ document , $ p );
141141 $ revertPatch [] = $ Operation ->getRevertPatch ($ p );
@@ -144,7 +144,7 @@ public function apply(string $patch): void
144144 foreach (array_reverse ($ revertPatch ) as $ p ) {
145145 if (!is_null ($ p )) {
146146 $ p = (object ) $ p ;
147- $ this ->operations [$ p ->op ]->apply ($ this ->document , $ p );
147+ $ this ->operationHandlers [$ p ->op ]->apply ($ this ->document , $ p );
148148 }
149149 }
150150
@@ -170,10 +170,10 @@ public function isValidPatch(string $patch): bool
170170 {
171171 try {
172172 foreach ($ this ->patchIterator ($ patch ) as $ op => $ p ) {
173- if (!isset ($ this ->operations [$ op ])) {
173+ if (!isset ($ this ->operationHandlers [$ op ])) {
174174 return false ;
175175 }
176- $ this ->operations [$ op ]->validate ($ p );
176+ $ this ->operationHandlers [$ op ]->validate ($ p );
177177 }
178178 return true ;
179179 } catch (FastJsonPatchException ) {
0 commit comments