src/Client.php
public function request($params)
  {
    $query = array_merge($params, [
      'key' => $this->key
    ]);

    try {

      $response = $this->client->get(self::API_ENDPOINT, [
        'query' => $query
      ]);

    } catch (ClientException $exception) {

      return collect([]);

    }

    $results = json_decode($response->getBody(), true);

    $output = [];

    for($i = 0; $i < count($results['itemListElement']); $i++) {
      $output[] = new SearchResult($results['itemListElement'][$i]);
    }

    return collect($output);
  }
public function request($params)
  {
    $query = array_merge($params, [
      'key' => $this->key
    ]);

    try {

      $response = $this->client->get(self::API_ENDPOINT, [
        'query' => $query
      ]);

    } catch (ClientException $exception) {

      return collect([]);

    }

    $results = json_decode($response->getBody(), true);

    $output = [];

    for($i = 0; $i < count($results['itemListElement']); $i++) {
      $output[] = new SearchResult($results['itemListElement'][$i]);
    }

    return collect($output);
  }
public function request ( $ params ) { $ query = array_merge ( $ params , [ 'key' => $ this -> key ] ) ; try { $ response = $ this -> client -> get ( self :: API_ENDPOINT , [ 'query' => $ query ] ) ; } catch ( ClientException $ exception ) { return collect ( [ ] ) ; } $ results = json_decode ( $ response -> getBody ( ) , true ) ; $ output = [ ] ; for ( $ i = 0 ; $ i < count ( $ results [ 'itemListElement' ] ) ; $ i ++ ) { $ output [ ] = new SearchResult ( $ results [ 'itemListElement' ] [ $ i ] ) ; } return collect ( $ output ) ; }
Make request to Knowledge Graph API

@var array $params

@return \Illuminate\Support\Collection Return collection of \KnowledgeGraph\Result
Make request to Knowledge Graph API