Skip to content

Commit

Permalink
Update Goutte to latest version removing the guzzlePHP dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rjd22 committed May 31, 2021
1 parent 306d423 commit 3a23e88
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
},
"require": {
"fabpot/goutte": "^3.2",
"php": "^7.1"
"php": "^7.1",
"fabpot/goutte": "^4.0"
},
"require-dev": {
"brianium/paratest": "~4.0",
Expand Down
8 changes: 4 additions & 4 deletions src/Jikan.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace Jikan;

use GuzzleHttp\Client as GuzzleClient;
use Jikan\Exception\ParserException;
use Jikan\Helper\Constants;
use Jikan\Model;
use Jikan\MyAnimeList\MalClient;
use Jikan\Request;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/**
* Class Jikan
Expand All @@ -33,11 +33,11 @@ class Jikan
/**
* Jikan constructor.
*
* @param GuzzleClient|null $guzzle
* @param HttpClientInterface|null $httpClient
*/
public function __construct(GuzzleClient $guzzle = null)
public function __construct(HttpClientInterface $httpClient = null)
{
$this->myanimelist = new MalClient($guzzle);
$this->myanimelist = new MalClient($httpClient);
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/MyAnimeList/MalClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace Jikan\MyAnimeList;

use GuzzleHttp\Client as GuzzleClient;
use Jikan\Exception\BadResponseException;
use Jikan\Exception\ParserException;
use Jikan\Goutte\GoutteWrapper;
use Jikan\Model;
use Jikan\Parser;
use Jikan\Request;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/**
* Class MalClient
Expand All @@ -32,16 +32,13 @@ class MalClient
/**
* MalClient constructor.
*
* @param GuzzleClient|null $guzzle
* @param HttpClientInterfac|null $httpClient
*
* @throws \InvalidArgumentException
*/
public function __construct(GuzzleClient $guzzle = null)
public function __construct(HttpClientInterface $httpClient = null)
{
$this->ghoutte = new GoutteWrapper();
if ($guzzle !== null) {
$this->ghoutte->setClient($guzzle);
}
$this->ghoutte = new GoutteWrapper($httpClient);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Parser/Forum/ForumTopicParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Jikan\Helper\Parser;
use Jikan\Model\Forum\ForumPost;
use Symfony\Component\DomCrawler\Crawler;
use function GuzzleHttp\Psr7\parse_query;

/**
* Class ForumPostParser
Expand Down Expand Up @@ -37,7 +36,7 @@ public function __construct(Crawler $crawler)
*/
public function getTopicId(): int
{
$query = parse_query(explode('?', $this->getUrl())[1]);
parse_str(explode('?', $this->getUrl())[1], $query);

return (int)$query['topicid'];
}
Expand Down

0 comments on commit 3a23e88

Please sign in to comment.