Rs\Json\Patch\Operation::__construct PHP Метод

__construct() публичный Метод

public __construct ( string $op, stdClass $operation )
$op string
$operation stdClass
    public function __construct($op, \stdClass $operation)
    {
        if (!class_exists('Rs\\Json\\Pointer')) {
            $exceptionMessage = 'Unable to create JSON patch operation as ' . 'Json Pointer is not installed';
            throw new \RuntimeException($exceptionMessage);
        }
        if (!property_exists($operation, 'path')) {
            $exceptionMessage = sprintf("No path property set for patch operation '%s'", json_encode($operation));
            throw new InvalidOperationException($exceptionMessage);
        }
        $this->name = $op;
        $this->path = $operation->path;
        $this->value = property_exists($operation, 'value') ? $operation->value : null;
    }

Usage Example

Пример #1
0
 /**
  * @param \stdClass $operation
  *
  * @throws \Rs\Json\Patch\InvalidOperationException
  * @throws \RuntimeException
  */
 public function __construct(\stdClass $operation)
 {
     $this->assertMandatories($operation);
     parent::__construct('move', $operation);
     $this->from = $operation->from;
 }
All Usage Examples Of Rs\Json\Patch\Operation::__construct