コード例 #1
0
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * @dataProvider createDataProvider
  *
  * @param mixed  $expected
  * @param array  $document
  * @param string $path
  * @param mixed  $value
  * @param bool   $success
  */
 public function testCreate($expected, $document, $path, $value, $success)
 {
     if ($success) {
         $this->facade->create($document, new JsonPointer($path), $value);
         $this->assertEquals($expected, $document);
     } else {
         $this->setExpectedException('\\ChiliLabs\\JsonPointer\\Exception\\InvalidPathException');
         $this->facade->create($document, new JsonPointer($path), $value);
     }
 }