/** * * 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; } } }
/** * @covers Peach\DF\JsonCodec\StructuralChar::handle * @covers Peach\DF\JsonCodec\StructuralChar::handleChar * @covers Peach\DF\JsonCodec\StructuralChar::getResult */ public function testHandleAndGetResult() { $context = new Context(" } ", new ArrayMap()); $expr = new StructuralChar(array(",", "}")); $expr->handle($context); $this->assertSame("}", $expr->getResult()); }