src/JsonStream.php
private function calculatePosition($offset, $whence)
    {
        if ($whence === SEEK_CUR) {
            return max(0, $this->cursor + (int) $offset);
        } elseif ($whence === SEEK_SET) {
            return max(0, (int) $offset);
        } elseif ($whence === SEEK_END) {
            throw new \RuntimeException('Cannot set cursor position from the end of a JSON stream');
        }

        throw new \InvalidArgumentException("Invalid cursor relative position '$whence'");
    }
private function calculatePosition($offset, $whence)
    {
        if ($whence === SEEK_CUR) {
            return max(0, $this->cursor + (int) $offset);
        } elseif ($whence === SEEK_SET) {
            return max(0, (int) $offset);
        } elseif ($whence === SEEK_END) {
            throw new \RuntimeException('Cannot set cursor position from the end of a JSON stream');
        }

        throw new \InvalidArgumentException("Invalid cursor relative position '$whence'");
    }
private function calculatePosition ( $ offset , $ whence ) { if ( $ whence === SEEK_CUR ) { return max ( 0 , $ this -> cursor + ( int ) $ offset ) ; } elseif ( $ whence === SEEK_SET ) { return max ( 0 , ( int ) $ offset ) ; } elseif ( $ whence === SEEK_END ) { throw new \ RuntimeException ( 'Cannot set cursor position from the end of a JSON stream' ) ; } throw new \ InvalidArgumentException ( "Invalid cursor relative position '$whence'" ) ; }
Calculates new position for the cursor based on offset and whence.
@param int $offset The cursor offset
@param int $whence One of the SEEK_* constants
@return int The new cursor position
@throws \RuntimeException If SEEK_END is used to determine the cursor position
Calculates new position for the cursor based on offset and whence .