public function peek($length = null, $start = null)
    {
        $this->lastPeekResult = null;
        $this->nextConsumeLength = null;

        if (!$this->hasLength()) {
            return;
        }

        $length = $length !== null ? $length : 1;
        $start = $start !== null ? $start : 0;

        if (!is_int($length) || $length < 1) {
            throw new \InvalidArgumentException(
                'Failed to peek: Length should be a number above 1'
            );
        }

        //Cap read length to the size of this document
        if ($length > ($maxLength = $this->getLength())) {
            $length = $maxLength;
        }

        $this->lastPeekResult = mb_substr($this->input, $start, $length, $this->encoding);
        $this->nextConsumeLength = $start + $length;

        return $this->lastPeekResult;
    }
public function peek($length = null, $start = null)
    {
        $this->lastPeekResult = null;
        $this->nextConsumeLength = null;

        if (!$this->hasLength()) {
            return;
        }

        $length = $length !== null ? $length : 1;
        $start = $start !== null ? $start : 0;

        if (!is_int($length) || $length < 1) {
            throw new \InvalidArgumentException(
                'Failed to peek: Length should be a number above 1'
            );
        }

        //Cap read length to the size of this document
        if ($length > ($maxLength = $this->getLength())) {
            $length = $maxLength;
        }

        $this->lastPeekResult = mb_substr($this->input, $start, $length, $this->encoding);
        $this->nextConsumeLength = $start + $length;

        return $this->lastPeekResult;
    }
public function peek ( $ length = null , $ start = null ) { $ this -> lastPeekResult = null ; $ this -> nextConsumeLength = null ; if ( ! $ this -> hasLength ( ) ) { return ; } $ length = $ length !== null ? $ length : 1 ; $ start = $ start !== null ? $ start : 0 ; if ( ! is_int ( $ length ) || $ length < 1 ) { throw new \ InvalidArgumentException ( 'Failed to peek: Length should be a number above 1' ) ; } //Cap read length to the size of this document if ( $ length > ( $ maxLength = $ this -> getLength ( ) ) ) { $ length = $ maxLength ; } $ this -> lastPeekResult = mb_substr ( $ this -> input , $ start , $ length , $ this -> encoding ) ; $ this -> nextConsumeLength = $ start + $ length ; return $ this -> lastPeekResult ; }
Peeks one or multiple characters without moving the pointer forward.

The peeked length will be stored and can be consumed with `consume()` later on.

@param int $length the length to consume (default: 1).
@param int $start  the offset to start on based on the current offset (default: 0).

@return string|null the peeked string or null if reading is finished.
Peeks one or multiple characters without moving the pointer forward .