php-jsonpatch
php-jsonpatch copied to clipboard
BC Break: Add method to convert patched document to array
I think it is very common to convert the patched document to an array afterwards. This given, it would be nice to add a method which handles this within the lib.
I imagine an API like
$patchedArray = (new Patch($targetDocument, $patchDocument))->apply()->toArray();
$patchedDocument = (new Patch($targetDocument, $patchDocument))->apply()->toJson();
This implies that apply() does just return $this.
If this is a valuable feature I will add a PR.
I +1 this feature because I currently use: json_decode($patch->apply()); So a toArray() and toJson() via returning $this; would be very helpful
As this got a +1 I would accept a PR implementing this.