private function assertValidState(): void
    {
        if (null !== $this->authority && ('' !== $this->path && '/' !== $this->path[0])) {
            throw new SyntaxError('If an authority is present the path must be empty or start with a `/`');
        }

        if (null === $this->authority && 0 === strpos($this->path, '//')) {
            throw new SyntaxError(sprintf('If there is no authority the path `%s` can not start with a `//`', $this->path));
        }

        $pos = strpos($this->path, ':');
        if (null === $this->authority
            && null === $this->scheme
            && false !== $pos
            && false === strpos(substr($this->path, 0, $pos), '/')
        ) {
            throw new SyntaxError('In absence of a scheme and an authority the first path segment cannot contain a colon (":") character.');
        }

        $validationMethod = self::SCHEME_VALIDATION_METHOD[$this->scheme] ?? null;
        if (null === $validationMethod || true === $this->$validationMethod()) {
            $this->uri = null;

            return;
        }

        throw new SyntaxError(sprintf('The uri `%s` is invalid for the data scheme', (string) $this));
    }
private function assertValidState(): void
    {
        if (null !== $this->authority && ('' !== $this->path && '/' !== $this->path[0])) {
            throw new SyntaxError('If an authority is present the path must be empty or start with a `/`');
        }

        if (null === $this->authority && 0 === strpos($this->path, '//')) {
            throw new SyntaxError(sprintf('If there is no authority the path `%s` can not start with a `//`', $this->path));
        }

        $pos = strpos($this->path, ':');
        if (null === $this->authority
            && null === $this->scheme
            && false !== $pos
            && false === strpos(substr($this->path, 0, $pos), '/')
        ) {
            throw new SyntaxError('In absence of a scheme and an authority the first path segment cannot contain a colon (":") character.');
        }

        $validationMethod = self::SCHEME_VALIDATION_METHOD[$this->scheme] ?? null;
        if (null === $validationMethod || true === $this->$validationMethod()) {
            $this->uri = null;

            return;
        }

        throw new SyntaxError(sprintf('The uri `%s` is invalid for the data scheme', (string) $this));
    }
private function assertValidState ( ) : void { if ( null !== $ this -> authority && ( '' !== $ this -> path && '/' !== $ this -> path [ 0 ] ) ) { throw new SyntaxError ( 'If an authority is present the path must be empty or start with a `/`' ) ; } if ( null === $ this -> authority && 0 === strpos ( $ this -> path , '//' ) ) { throw new SyntaxError ( sprintf ( 'If there is no authority the path `%s` can not start with a `//`' , $ this -> path ) ) ; } $ pos = strpos ( $ this -> path , ':' ) ; if ( null === $ this -> authority && null === $ this -> scheme && false !== $ pos && false === strpos ( substr ( $ this -> path , 0 , $ pos ) , '/' ) ) { throw new SyntaxError ( 'In absence of a scheme and an authority the first path segment cannot contain a colon (":") character.' ) ; } $ validationMethod = self :: SCHEME_VALIDATION_METHOD [ $ this -> scheme ] ?? null ; if ( null === $ validationMethod || true === $ this -> $ validationMethod ( ) ) { $ this -> uri = null ; return ; } throw new SyntaxError ( sprintf ( 'The uri `%s` is invalid for the data scheme' , ( string ) $ this ) ) ; }
assert the URI internal state is valid.

@see https://tools.ietf.org/html/rfc3986#section-3
@see https://tools.ietf.org/html/rfc3986#section-3.3

@throws SyntaxError if the URI is in an invalid state according to RFC3986
@throws SyntaxError if the URI is in an invalid state according to scheme specific rules
assert the URI internal state is valid .