perform() public method

public perform ( string $targetDocument ) : string
$targetDocument string
return string
Example #1
0
 /**
  * @param  string $targetDocument
  *
  * @throws \Rs\Json\Patch\InvalidOperationException
  * @throws \Rs\Json\Pointer\InvalidJsonException
  * @throws \Rs\Json\Pointer\InvalidPointerException
  * @throws \Rs\Json\Pointer\NonWalkableJsonException
  * @throws \RuntimeException
  * @return string
  */
 public function perform($targetDocument)
 {
     $pointer = new Pointer($targetDocument);
     try {
         $get = $pointer->get($this->getFrom());
     } catch (NonexistentValueReferencedException $e) {
         return $targetDocument;
     }
     if ($this->getFrom() === $this->getPath()) {
         return $targetDocument;
     }
     $operation = new \stdClass();
     $operation->path = $this->getPath();
     $operation->value = $get;
     $add = new Add($operation);
     return $add->perform($targetDocument);
 }