src/Language/Source.php
public function getLocation($position)
    {
        $pattern = '/\r\n|[\n\r\u2028\u2029]/g';
        $subject = mb_substr($this->body, 0, $position, 'UTF-8');

        preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
        $location = array_reduce($matches[0], function ($carry, $match) use ($position) {
            return [
                $carry[0] + 1,
                $position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'))
            ];
        }, [1, $position + 1]);

        return new SourceLocation($location[0], $location[1]);
    }
public function getLocation($position)
    {
        $pattern = '/\r\n|[\n\r\u2028\u2029]/g';
        $subject = mb_substr($this->body, 0, $position, 'UTF-8');

        preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
        $location = array_reduce($matches[0], function ($carry, $match) use ($position) {
            return [
                $carry[0] + 1,
                $position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'))
            ];
        }, [1, $position + 1]);

        return new SourceLocation($location[0], $location[1]);
    }
public function getLocation ( $ position ) { $ pattern = '/\r\n|[\n\r\u2028\u2029]/g' ; $ subject = mb_substr ( $ this -> body , 0 , $ position , 'UTF-8' ) ; preg_match_all ( $ pattern , $ subject , $ matches , PREG_OFFSET_CAPTURE ) ; $ location = array_reduce ( $ matches [ 0 ] , function ( $ carry , $ match ) use ( $ position ) { return [ $ carry [ 0 ] + 1 , $ position + 1 - ( $ match [ 1 ] + mb_strlen ( $ match [ 0 ] , 'UTF-8' ) ) ] ; } , [ 1 , $ position + 1 ] ) ; return new SourceLocation ( $ location [ 0 ] , $ location [ 1 ] ) ; }
Takes a Source and a UTF-8 character offset, and returns the
corresponding line and column as a SourceLocation.

@param $position

@return \Fubhy\GraphQL\Language\SourceLocation
Takes a Source and a UTF - 8 character offset and returns the corresponding line and column as a SourceLocation .