/** * @dataProvider setDataProvider * * @param mixed $expected * @param array $document * @param string $path * @param mixed $value * @param bool $success */ public function testSet($expected, $document, $path, $value, $success) { if ($success) { $this->facade->set($document, new JsonPointer($path), $value); $this->assertEquals($expected, $document); } else { $this->setExpectedException('\\ChiliLabs\\JsonPointer\\Exception\\InvalidPathException'); $this->facade->set($document, new JsonPointer($path), $value); } }
/** * {@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; }