/** * 現在の文字が数字 ("0" から "9") かどうかを調べます. * * @param Context $context 解析対象の Context * @return bool 現在の文字が 0 から 9 のいずれかの場合のみ true */ public static function checkDigit(Context $context) { $code = $context->currentCodePoint(); return 0x30 <= $code && $code <= 0x39; }
/** * @covers Peach\DF\JsonCodec\Context::currentCodePoint */ public function testCurrentCodePoint() { $context = new Context("Test", new ArrayMap()); $this->assertSame(0x54, $context->currentCodePoint()); $context->next(); $this->assertSame(0x65, $context->currentCodePoint()); $context->next(); $this->assertSame(0x73, $context->currentCodePoint()); $context->next(); $this->assertSame(0x74, $context->currentCodePoint()); $context->next(); $this->assertNull($context->currentCodePoint()); }