php-jsonpatch icon indicating copy to clipboard operation
php-jsonpatch copied to clipboard

BC Break: Add method to convert patched document to array

Open Konafets opened this issue 8 years ago • 2 comments

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.

Konafets avatar Jun 21 '17 10:06 Konafets

I +1 this feature because I currently use: json_decode($patch->apply()); So a toArray() and toJson() via returning $this; would be very helpful

lifewcody avatar Feb 26 '18 18:02 lifewcody

As this got a +1 I would accept a PR implementing this.

raphaelstolt avatar Mar 07 '18 11:03 raphaelstolt