/** * {@inheritdoc} */ public function __invoke($document, AccessFacade $access) { if (!$access->isWritable($document, $this->path)) { throw new OperationException(sprintf('The path "%s" does not exist.', (string) $this->path)); } $access->set($document, $this->path, $this->value); return $document; }
/** * {@inheritdoc} */ public function __invoke($document, AccessFacade $access) { if ($access->isReadable($document, $this->path) && $access->get($document, $this->path) !== null) { throw new OperationException(sprintf('The path "%s" does already exist.', (string) $this->path)); } $access->create($document, $this->path, $this->value); return $document; }
/** * {@inheritdoc} */ public function __invoke($document, AccessFacade $access) { if (!$access->isReadable($document, $this->from)) { throw new OperationException(sprintf('The path "%s" is not readable.', (string) $this->from)); } $value = $access->get($document, $this->from); $addOperation = new AddOperation($this->path, $value); $document = $addOperation($document, $access); return $document; }
/** * {@inheritdoc} */ public function __invoke($document, AccessFacade $access) { if (!$access->isReadable($document, $this->path)) { throw new OperationException(sprintf('The path "%s" does not exist.', (string) $this->path)); } $value = $access->get($document, $this->path); if ($value != $this->value) { throw new OperationException(sprintf('Test failed: Values do not match (%s != %s).', $value, $this->value)); } return $document; }
/** * @dataProvider isWritableDataProvider * * @param mixed $expected * @param array $document * @param string $path */ public function testIsWritable($expected, $document, $path) { $result = $this->facade->isWritable($document, new JsonPointer($path)); $this->assertEquals($expected, $result); }