Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Conflicts:
	composer.json
  • Loading branch information
victuxbb committed Jan 12, 2015
2 parents 4e6b430 + 09c8092 commit ac4618c
Show file tree
Hide file tree
Showing 17 changed files with 454 additions and 245 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
vendor/
.idea
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
jsonpatch
=========

Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902) in PHP using JSON Pointer from:
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/dee95637-0141-4caa-b6bf-1189a848128c/big.png)](https://insight.sensiolabs.com/projects/dee95637-0141-4caa-b6bf-1189a848128c)

https://github.com/webnium/php-json-pointer
Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902) in PHP

Currently still developing, in the next couple of days I will post documentation and some refactors.
Installation
-------------
Require [`victuxbb/jsonpatch`](https://packagist.org/packages/victuxbb/jsonpatch)
into your `composer.json` file:

Example of test.php
``` json
{
"require": {
"victuxbb/jsonpatch": "@stable"
}
}
```

<?php
Documentation
-------------
``` php

require 'vendor/autoload.php';
use victuxbb\JsonPatch\Patcher;
$targetJSON ='{"baz": "qux","foo": "bar"}';
$patchOperations = '[
{ "op": "replace", "path": "/baz", "value": "boo" }
]';
$expected ='{"baz":"boo","foo":"bar"}';

$patcher = new Patcher();
$result = $patcher->patch($targetJSON,$patchOperations);

$targetJSON ='{"a":{"b":["c","d","e"]}}';
```

$patchDocument = '[
{"op":"add", "path":"/a/d", "value":["a","b"]},
{"op":"move", "path":"/a/c", "from":"/a/d"},
{"op":"copy", "path":"/a/e", "from":"/a/c"},
{"op":"replace", "path":"/a/e", "value":["a"]}
]';
Thanks to
---------

$result = $patcher->patch($targetJSON,$patchDocument);
*https://github.com/webnium

print_r($result);
*https://github.com/javadegava

Thanks to:
*http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/

https://github.com/webnium
https://github.com/javadegava
http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/
http://www.groupalia.com/
*http://www.groupalia.com/
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
}
],
"require": {
"php": ">=5.3.3",
"webnium/json-pointer": "dev-master"
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "4.3.*"
Expand Down
78 changes: 13 additions & 65 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 0 additions & 46 deletions src/victuxbb/JsonPatch/ArrayAccessor.php

This file was deleted.

13 changes: 13 additions & 0 deletions src/victuxbb/JsonPatch/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* This file is part of webnium/json-pointer.
*/

namespace victuxbb\JsonPatch\Exception;

/**
* Interface for Exception
*/
interface ExceptionInterface
{
}
15 changes: 15 additions & 0 deletions src/victuxbb/JsonPatch/Exception/NoneExistentValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of webnium/json-pointer.
*/

namespace victuxbb\JsonPatch\Exception;

/**
* None existent value exception.
*
* This exception will be thrown when a pointer references none existent value.
*/
class NoneExistentValue extends \RuntimeException implements ExceptionInterface
{
}
15 changes: 15 additions & 0 deletions src/victuxbb/JsonPatch/Exception/SyntaxError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of webnium/json-pointer.
*/

namespace victuxbb\JsonPatch\Exception;

/**
* SyntaxError exception.
*
* This Exception will be thrown when a JSON Pointer has syntax error.
*/
class SyntaxError extends \RuntimeException implements ExceptionInterface
{
}
Loading

0 comments on commit ac4618c

Please sign in to comment.