You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Support building & using patches as a list of DTOs
Build on the existing implementation to allow users to specify patches
as a list of operation objects, rather than as a JSON string.
Unlike the JSON form, the patch operation DTOs are strict about the
parameters they accept. If a user wishes to include custom properties,
they can implement a class extending the base `PatchOperation`.
Patch DTOs can be serialised to and from JSON, for convenience.
Copy file name to clipboardExpand all lines: README.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,64 @@ The expected workflow is that once you got a `FastJsonPatch` instance you can ca
90
90
91
91
Patch application is designed to be atomic. If any operation of a given patch fails the original document is restored, ensuring a consistent state of the document.
92
92
93
+
If you are building patches within your application, rather than receiving them from an external source, you may wish
94
+
to build them as native PHP objects. This provides strict typing of the available parameters for each operation.
95
+
96
+
The above example could also be represented as:
97
+
98
+
```php
99
+
use blancks\JsonPatch\FastJsonPatch;
100
+
use blancks\JsonPatch\exceptions\FastJsonPatchException;
101
+
use blancks\JsonPatch\operations\PatchOperationList;
0 commit comments