diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index b6cf901..beb463c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -83,7 +83,7 @@ SQL )) ->where('user_id', $user->id) ->groupBy(DB::raw("to_char(ejaculated_date, 'HH24')")) - ->orderBy(DB::raw("1")) + ->orderBy(DB::raw('1')) ->get(); $dailySum = []; diff --git a/app/MetadataResolver/DLsiteResolver.php b/app/MetadataResolver/DLsiteResolver.php index ac1a717..fc0d522 100644 --- a/app/MetadataResolver/DLsiteResolver.php +++ b/app/MetadataResolver/DLsiteResolver.php @@ -11,7 +11,7 @@ class DLsiteResolver implements Resolver if ($res->getStatusCode() === 200) { $ogpResolver = new OGPResolver(); $metadata = $ogpResolver->parse($res->getBody()); - $metadata->image = str_replace("img_sam.jpg", "img_main.jpg", $metadata->image); + $metadata->image = str_replace('img_sam.jpg', 'img_main.jpg', $metadata->image); return $metadata; } else { diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php index 8a998c4..0a5e5b3 100644 --- a/app/MetadataResolver/FantiaResolver.php +++ b/app/MetadataResolver/FantiaResolver.php @@ -25,7 +25,7 @@ class FantiaResolver implements Resolver $ogpUrl = $node->getAttribute('content'); // 投稿に画像がない場合(ogp.jpgでない場合)のみ大きい画像に変換する - if ($ogpUrl != "http://fantia.jp/images/ogp.jpg") { + if ($ogpUrl != 'http://fantia.jp/images/ogp.jpg') { preg_match("~https://fantia\.s3\.amazonaws\.com/uploads/post/file/{$postId}/ogp_(.*?)\.(jpg|png)~", $ogpUrl, $match); $uuid = $match[1]; $extension = $match[2]; diff --git a/app/MetadataResolver/FanzaResolver.php b/app/MetadataResolver/FanzaResolver.php index 4f4941d..de06b75 100644 --- a/app/MetadataResolver/FanzaResolver.php +++ b/app/MetadataResolver/FanzaResolver.php @@ -11,7 +11,7 @@ class FanzaResolver implements Resolver if ($res->getStatusCode() === 200) { $ogpResolver = new OGPResolver(); $metadata = $ogpResolver->parse($res->getBody()); - $metadata->image = preg_replace("~(pr|ps)\.jpg$~", "pl.jpg", $metadata->image); + $metadata->image = preg_replace("~(pr|ps)\.jpg$~", 'pl.jpg', $metadata->image); return $metadata; } else { diff --git a/app/MetadataResolver/KomifloResolver.php b/app/MetadataResolver/KomifloResolver.php index 04b6248..8fb569c 100644 --- a/app/MetadataResolver/KomifloResolver.php +++ b/app/MetadataResolver/KomifloResolver.php @@ -23,7 +23,7 @@ class KomifloResolver implements Resolver $metadata->description = ($json['content']['attributes']['artists']['children'][0]['data']['name'] ?? '?') . ' - ' . ($json['content']['parents'][0]['data']['title'] ?? '?'); - $metadata->image = $json['content']['cdn_public'] . "/564_mobile_large_3x/" . $json['content']['named_imgs']['cover']['filename'] . $json['content']['signature']; + $metadata->image = $json['content']['cdn_public'] . '/564_mobile_large_3x/' . $json['content']['named_imgs']['cover']['filename'] . $json['content']['signature']; $metadata->expires_at = Carbon::parse($json['content']['signature_expires'])->setTimezone(config('app.timezone')); return $metadata; diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index b859675..ca5463c 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -12,8 +12,8 @@ class PixivResolver implements Resolver */ public function thumbnailToMasterUrl(string $thumbnailUrl): string { - $temp = str_replace("/c/128x128", "", $thumbnailUrl); - $largeUrl = str_replace("square1200.jpg", "master1200.jpg", $temp); + $temp = str_replace('/c/128x128', '', $thumbnailUrl); + $largeUrl = str_replace('square1200.jpg', 'master1200.jpg', $temp); return $largeUrl; } @@ -27,21 +27,21 @@ class PixivResolver implements Resolver */ public function proxize(string $pixivUrl): string { - return str_replace("i.pximg.net", "i.pixiv.cat", $pixivUrl); + return str_replace('i.pximg.net', 'i.pixiv.cat', $pixivUrl); } public function resolve(string $url): Metadata { - preg_match("~illust_id=(\d+)~", parse_url($url)["query"], $match); + preg_match("~illust_id=(\d+)~", parse_url($url)['query'], $match); $illustId = $match[1]; // 漫画ページかつページ数あり - if (strpos(parse_url($url)["query"], "mode=manga_big") && strpos(parse_url($url)["query"], "page=")) { - preg_match("~page=(\d+)~", parse_url($url)["query"], $match); + if (strpos(parse_url($url)['query'], 'mode=manga_big') && strpos(parse_url($url)['query'], 'page=')) { + preg_match("~page=(\d+)~", parse_url($url)['query'], $match); $page = $match[1]; // 未ログインでは漫画ページを開けないため、URL を作品ページに変換する - $url = str_replace("mode=manga_big", "mode=medium", $url); + $url = str_replace('mode=manga_big', 'mode=medium', $url); $client = new \GuzzleHttp\Client(); $res = $client->get($url); @@ -55,7 +55,7 @@ class PixivResolver implements Resolver $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); // 指定ページに変換 - $illustUrl = str_replace("p0_master", "p{$page}_master", $illustUrl); + $illustUrl = str_replace('p0_master', "p{$page}_master", $illustUrl); $metadata->image = $this->proxize($illustUrl); @@ -71,10 +71,10 @@ class PixivResolver implements Resolver $metadata = $ogpResolver->parse($res->getBody()); // OGP がデフォルト画像であるようならなんとかして画像を取得する - if (strpos($metadata->image, "pixiv_logo.gif") || strpos($metadata->image, "pictures.jpg")) { + if (strpos($metadata->image, 'pixiv_logo.gif') || strpos($metadata->image, 'pictures.jpg')) { // 作品ページの場合のみ対応 - if (strpos(parse_url($url)["query"], "mode=medium")) { + if (strpos(parse_url($url)['query'], 'mode=medium')) { preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illustId}(_p0)?_square1200\.jpg~", $res->getBody(), $match); $illustThumbnailUrl = $match[0]; diff --git a/database/migrations/2019_01_15_143800_add_expires_on_metadata.php b/database/migrations/2019_01_15_143800_add_expires_on_metadata.php index 46891e1..673588e 100644 --- a/database/migrations/2019_01_15_143800_add_expires_on_metadata.php +++ b/database/migrations/2019_01_15_143800_add_expires_on_metadata.php @@ -1,8 +1,8 @@ resolve('https://nijie.info/view.php?id=9537'); $this->assertEquals('ニジエがgifに対応したんだってね 奥さん | 黒末アプコ', $metadata->title); - $this->assertEquals("アニメgifとか専門外なのでよくわかりませんでした", $metadata->description); + $this->assertEquals('アニメgifとか専門外なのでよくわかりませんでした', $metadata->description); $this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image); } @@ -84,7 +84,7 @@ class NijieResolverTest extends TestCase $metadata = $resolver->resolve('https://nijie.info/view.php?id=9537'); $this->assertEquals('ニジエがgifに対応したんだってね 奥さん | 黒末アプコ', $metadata->title); - $this->assertEquals("アニメgifとか専門外なのでよくわかりませんでした", $metadata->description); + $this->assertEquals('アニメgifとか専門外なのでよくわかりませんでした', $metadata->description); $this->assertRegExp('~/nijie\.info/pic/logo~', $metadata->image); } diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php index dd9f0a2..fca2fba 100644 --- a/tests/Unit/Utilities/FormatterTest.php +++ b/tests/Unit/Utilities/FormatterTest.php @@ -54,4 +54,4 @@ class FormatterTest extends TestCase $url = 'http://example.com/path/to?foo=bar&hoge=fuga#'; $this->assertEquals('http://example.com/path/to?foo=bar&hoge=fuga', $formatter->normalizeUrl($url)); } -} \ No newline at end of file +}