Esempio n. 1
0
 /**
  * 
  * Context $context
  */
 public function handle(Context $context)
 {
     $beginObject = new StructuralChar(array("{"));
     $beginObject->handle($context);
     $container = $this->getContainer($context);
     if ($context->current() === "}") {
         $endObject = new StructuralChar(array("}"));
         $endObject->handle($context);
         $this->result = $container->getResult();
         return;
     }
     while (true) {
         if ($context->current() === "}") {
             $context->throwException("Closing bracket after comma is not permitted");
         }
         $member = new Member();
         $member->handle($context);
         $container->setMember($member);
         $struct = new StructuralChar(array(",", "}"));
         $struct->handle($context);
         if ($struct->getResult() === "}") {
             $this->result = $container->getResult();
             break;
         }
     }
 }
Esempio n. 2
0
 /**
  * @covers Peach\DF\JsonCodec\StructuralChar::handle
  * @covers Peach\DF\JsonCodec\StructuralChar::handleChar
  * @expectedException Peach\DF\JsonCodec\DecodeException
  * @expectedExceptionMessage 'x' is not allowed (expected: ',', '}') at line 3, column 4
  */
 public function testHandleFailByInvalidChar()
 {
     $context = new Context("    \n        \r   x   \r\n    ", new ArrayMap());
     $expr = new StructuralChar(array(",", "}"));
     $expr->handle($context);
 }