Guzzle\Clientをモッカブルにする
This commit is contained in:
@@ -2,8 +2,20 @@
|
||||
|
||||
namespace App\MetadataResolver;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class KomifloResolver implements Resolver
|
||||
{
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function resolve(string $url): Metadata
|
||||
{
|
||||
if (preg_match('~komiflo\.com(?:/#!)?/comics/(\\d+)~', $url, $matches) !== 1) {
|
||||
@@ -11,8 +23,7 @@ class KomifloResolver implements Resolver
|
||||
}
|
||||
$id = $matches[1];
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$res = $client->get('https://api.komiflo.com/content/id/' . $id);
|
||||
$res = $this->client->get('https://api.komiflo.com/content/id/' . $id);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
$json = json_decode($res->getBody()->getContents(), true);
|
||||
$metadata = new Metadata();
|
||||
|
Reference in New Issue
Block a user