src/IpInfoRepository.php
public function lookup($ip)
    {
        if ($ip == '127.0.0.1') {
          return (object)[
            'status'  => 'error',
            'errorMessage'  => 'Cannot lookup localhost'
          ];
        }
        if ($this->isReserved($ip)) {
            return (object)[
              'status'  => 'error',
              'errorMessage'  => 'Cannot lookup reserved ip'
            ];
        }
        $client = new Client();
        try {
          $response = $client->request(
            'GET',
            "http://ipinfo.io/{$ip}"
          );
          if ($response->getStatusCode() == "200") {
              return (object)[
                  'status'  => 'success',
                  'results' => json_decode($response->getBody()->getContents())
              ];
          } else {
              return (object)[
                'status'  => 'error',
                'errorMessage'  => $response->getStatusCode()
              ];
          }
        } catch (RequestException $e) {
            $this->error = $e->getMessage();
            return (object)[
              'status'  => 'error',
              'errorMessage'  => $this->error
            ];
        }
    }
public function lookup($ip)
    {
        if ($ip == '127.0.0.1') {
          return (object)[
            'status'  => 'error',
            'errorMessage'  => 'Cannot lookup localhost'
          ];
        }
        if ($this->isReserved($ip)) {
            return (object)[
              'status'  => 'error',
              'errorMessage'  => 'Cannot lookup reserved ip'
            ];
        }
        $client = new Client();
        try {
          $response = $client->request(
            'GET',
            "http://ipinfo.io/{$ip}"
          );
          if ($response->getStatusCode() == "200") {
              return (object)[
                  'status'  => 'success',
                  'results' => json_decode($response->getBody()->getContents())
              ];
          } else {
              return (object)[
                'status'  => 'error',
                'errorMessage'  => $response->getStatusCode()
              ];
          }
        } catch (RequestException $e) {
            $this->error = $e->getMessage();
            return (object)[
              'status'  => 'error',
              'errorMessage'  => $this->error
            ];
        }
    }
public function lookup ( $ ip ) { if ( $ ip == '127.0.0.1' ) { return ( object ) [ 'status' => 'error' , 'errorMessage' => 'Cannot lookup localhost' ] ; } if ( $ this -> isReserved ( $ ip ) ) { return ( object ) [ 'status' => 'error' , 'errorMessage' => 'Cannot lookup reserved ip' ] ; } $ client = new Client ( ) ; try { $ response = $ client -> request ( 'GET' , "http://ipinfo.io/{$ip}" ) ; if ( $ response -> getStatusCode ( ) == "200" ) { return ( object ) [ 'status' => 'success' , 'results' => json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ] ; } else { return ( object ) [ 'status' => 'error' , 'errorMessage' => $ response -> getStatusCode ( ) ] ; } } catch ( RequestException $ e ) { $ this -> error = $ e -> getMessage ( ) ; return ( object ) [ 'status' => 'error' , 'errorMessage' => $ this -> error ] ; } }
Query Ip lookup service for $ip

@param  string $ip
@return stdClass
Query Ip lookup service for $ip