public function getContent(string $url): string
    {
        if (false === filter_var($url, FILTER_VALIDATE_URL)) {
            throw new InvalidArgument(
                sprintf('"%s" must be called with a valid url. Got "%s" instead.', __METHOD__, $url)
            );
        }

        $ipAddress = parse_url($url, PHP_URL_QUERY);

        if (false === filter_var($ipAddress, FILTER_VALIDATE_IP)) {
            throw new InvalidArgument('URL must contain a valid query-string (an IP address, 127.0.0.1 for instance)');
        }

        $result = $this->geoIp2Provider
            ->{$this->geoIP2Model}($ipAddress)
            ->jsonSerialize();

        return json_encode($result);
    }
public function getContent(string $url): string
    {
        if (false === filter_var($url, FILTER_VALIDATE_URL)) {
            throw new InvalidArgument(
                sprintf('"%s" must be called with a valid url. Got "%s" instead.', __METHOD__, $url)
            );
        }

        $ipAddress = parse_url($url, PHP_URL_QUERY);

        if (false === filter_var($ipAddress, FILTER_VALIDATE_IP)) {
            throw new InvalidArgument('URL must contain a valid query-string (an IP address, 127.0.0.1 for instance)');
        }

        $result = $this->geoIp2Provider
            ->{$this->geoIP2Model}($ipAddress)
            ->jsonSerialize();

        return json_encode($result);
    }
public function getContent ( string $ url ) : string { if ( false === filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new InvalidArgument ( sprintf ( '"%s" must be called with a valid url. Got "%s" instead.' , __METHOD__ , $ url ) ) ; } $ ipAddress = parse_url ( $ url , PHP_URL_QUERY ) ; if ( false === filter_var ( $ ipAddress , FILTER_VALIDATE_IP ) ) { throw new InvalidArgument ( 'URL must contain a valid query-string (an IP address, 127.0.0.1 for instance)' ) ; } $ result = $ this -> geoIp2Provider -> { $ this -> geoIP2Model } ( $ ipAddress ) -> jsonSerialize ( ) ; return json_encode ( $ result ) ; }
Returns the content fetched from a given resource.

@param string $url (e.g. file://database?127.0.0.1)

@return string
Returns the content fetched from a given resource .