/** * int = zero / ( digit1-9 *DIGIT ) * * @param Context $context */ private function handleIntegralPart(Context $context) { // check zero if ($context->current() === "0") { if (preg_match("/^0[0-9]\$/", $context->getSequence(2))) { $context->throwException("Integral part must not start with 0"); } $this->result .= "0"; $context->next(); return; } // check ( digit1-9 *DIGIT ) $this->handleFirstDigit($context); $this->handleDigitSequence($context); }
/** * @covers Peach\DF\JsonCodec\Context::getSequence * @covers Peach\DF\JsonCodec\Context::encodeIndex */ public function testGetSequence() { $context = new Context("This is a pen.", new ArrayMap()); // read "this " $context->skip(5); $this->assertSame("is a", $context->getSequence(4)); // read "is a " $context->skip(5); $this->assertSame("pen.", $context->getSequence(10)); }