Skip to content

Commit

Permalink
Use a faster cURL package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jleagle committed Nov 28, 2015
1 parent 3897040 commit 8fd37f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"name": "jleagle/omdb-imdb-api-client",
"keywords": [
"name": "jleagle/omdb-imdb-api-client",
"keywords": [
"imdb",
"omdb",
"api",
"client",
"helper"
],
"description": "A package to retrieve movies and TV information from IMDB using the API at omdbapi.com",
"license": "MIT",
"authors": [
"license": "MIT",
"authors": [
{
"name": "James Eagle",
"email": "jimeagle@gmail.com",
"name": "James Eagle",
"email": "jimeagle@gmail.com",
"homepage": "http://jimeagle.com"
}
],
"require": {
"php": ">=5.4",
"guzzlehttp/guzzle": "~5.0"
"require": {
"php": ">=5.4",
"jleagle/curl-wrapper": "~0.1"
},
"require-dev": {
"phpunit/phpunit": "~4.6"
"phpunit/phpunit": "~5.0"
},
"autoload": {
"autoload": {
"psr-4": {
"Jleagle\\Imdb\\": "src/"
}
Expand Down
20 changes: 13 additions & 7 deletions src/Imdb.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace Jleagle\Imdb;

use GuzzleHttp\Client;
use Jleagle\CurlWrapper\Curl;
use Jleagle\CurlWrapper\Exceptions\CurlException;
use Jleagle\Imdb\Exceptions\ImdbException;
use Jleagle\Imdb\Responses\Movie;
use Jleagle\Imdb\Responses\Result;
Expand Down Expand Up @@ -110,7 +111,7 @@ public static function search($search, $movieType = null, $year = null)
*
* @return bool
*/
private static function isValidId($string)
protected static function isValidId($string)
{
return preg_match("/tt\\d{7}/", $string) > 0;
}
Expand All @@ -122,17 +123,22 @@ private static function isValidId($string)
*
* @throws ImdbException
*/
private static function _get($params)
protected static function _get($params)
{
$params = array_filter($params);

$params['r'] = 'json';
$params['v'] = '1';

$client = new Client();
$response = $client
->get('http://www.omdbapi.com/', ['query' => $params])
->json();
try
{
$response = Curl::get('http://www.omdbapi.com/', $params)
->run()->getJson();
}
catch(CurlException $e)
{
throw new ImdbException($e->getResponse()->getErrorMessage());
}

if(isset($response['Response']) && $response['Response'] == 'False')
{
Expand Down

0 comments on commit 8fd37f2

Please sign in to comment.