Merge pull request #113 from hinaloe/fix/issue-110

コンテナ使っていないコンストラクタが残ってた fix #110
This commit is contained in:
shibafu 2019-03-01 00:13:50 +09:00 committed by GitHub
commit eb97f01c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
namespace App\MetadataResolver; namespace App\MetadataResolver;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException; use GuzzleHttp\Exception\ServerException;
@ -67,7 +68,7 @@ class MetadataResolver implements Resolver
// Acceptヘッダには */* を足さないことにする。 // Acceptヘッダには */* を足さないことにする。
$acceptTypes = array_diff(array_keys($this->mimeTypes), ['*/*']); $acceptTypes = array_diff(array_keys($this->mimeTypes), ['*/*']);
$client = new \GuzzleHttp\Client(); $client = app(Client::class);
$res = $client->request('GET', $url, [ $res = $client->request('GET', $url, [
'headers' => [ 'headers' => [
'Accept' => implode(', ', $acceptTypes) 'Accept' => implode(', ', $acceptTypes)
@ -80,14 +81,14 @@ class MetadataResolver implements Resolver
if (isset($this->mimeTypes[$mimeType])) { if (isset($this->mimeTypes[$mimeType])) {
$class = $this->mimeTypes[$mimeType]; $class = $this->mimeTypes[$mimeType];
$parser = new $class(); $parser = app($class);
return $parser->parse($res->getBody()); return $parser->parse($res->getBody());
} }
if (isset($this->mimeTypes['*/*'])) { if (isset($this->mimeTypes['*/*'])) {
$class = $this->mimeTypes['*/*']; $class = $this->mimeTypes['*/*'];
$parser = new $class(); $parser = app($class);
return $parser->parse($res->getBody()); return $parser->parse($res->getBody());
} }