# bit-form/3.1.0/vendor/arif-un/jcof/src/StringReader.php

Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator &amp; Custom Form Builder, version 3.1.0. 53 lines.

- Page: https://pluginprobe.com/plugins/bit-form/3.1.0/code/vendor/arif-un/jcof/src/StringReader.php
- Raw: https://pluginprobe.com/plugins/bit-form/3.1.0/raw/vendor/arif-un/jcof/src/StringReader.php
- Modified: 2024-06-29T11:34:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bit-form/3.1.0/code/vendor/arif-un/jcof/src/StringReader.php#L10-L20`.

```php
<?php

namespace BitCode\BitForm\Jcof;

class StringReader
{
    public $str;

    public $index;

    public function __construct($str)
    {
        $this->str = $str;
        $this->index = 0;
    }

    public function peek()
    {
        if ($this->index >= strlen($this->str)) {
            return null;
        } else {
            return substr($this->str, $this->index, 1);
        }
    }

    public function consume()
    {
        $this->index += 1;
    }

    public function skip($ch)
    {
        $peeked = $this->peek();
        if ($peeked != $ch) {
            $this->error("Unexpected char: Expected '".$ch."', got '".$peeked."'");
        }

        $this->consume();
    }

    public function maybeSkip($ch)
    {
        if ($this->peek() == $ch) {
            $this->consume();
        }
    }

    public function error($msg)
    {
        throw new ParseErrors($msg, $this->index);
    }
}

```
