diff --git a/app/Exceptions/CsvImportException.php b/app/Exceptions/CsvImportException.php index 5571dc6..0682513 100644 --- a/app/Exceptions/CsvImportException.php +++ b/app/Exceptions/CsvImportException.php @@ -2,6 +2,7 @@ namespace App\Exceptions; +use Illuminate\Support\Arr; use Throwable; class CsvImportException extends \RuntimeException @@ -15,7 +16,7 @@ class CsvImportException extends \RuntimeException */ public function __construct(...$errors) { - parent::__construct(array_first($errors)); + parent::__construct(Arr::first($errors)); $this->errors = $errors; } diff --git a/app/MetadataResolver/NijieResolver.php b/app/MetadataResolver/NijieResolver.php index 4bbe5ca..879fdaf 100644 --- a/app/MetadataResolver/NijieResolver.php +++ b/app/MetadataResolver/NijieResolver.php @@ -3,6 +3,7 @@ namespace App\MetadataResolver; use GuzzleHttp\Client; +use Illuminate\Support\Str; use Symfony\Component\DomCrawler\Crawler; class NijieResolver implements Resolver @@ -50,8 +51,8 @@ class NijieResolver implements Resolver $metadata->description = '投稿者: ' . $data['author']['name'] . PHP_EOL . $data['description']; if ( isset($data['thumbnailUrl']) && - !ends_with($data['thumbnailUrl'], '.gif') && - !ends_with($data['thumbnailUrl'], '.mp4') + !Str::endsWith($data['thumbnailUrl'], '.gif') && + !Str::endsWith($data['thumbnailUrl'], '.mp4') ) { // サムネイルからメイン画像に $metadata->image = str_replace('__rs_l160x160/', '', $data['thumbnailUrl']); diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index c0401c9..7ac108b 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -2,6 +2,7 @@ namespace App\Utilities; +use Illuminate\Support\Str; use Misd\Linkify\Linkify; class Formatter @@ -55,10 +56,10 @@ class Formatter $parts = parse_url($url); if (!empty($parts['query'])) { // Remove query parameters - $url = str_replace_last('?' . $parts['query'], '', $url); + $url = Str::replaceFirst('?' . $parts['query'], '', $url); if (!empty($parts['fragment'])) { // Remove fragment identifier - $url = str_replace_last('#' . $parts['fragment'], '', $url); + $url = Str::replaceFirst('#' . $parts['fragment'], '', $url); } else { // "http://example.com/?query#" の場合 $parts['fragment'] は unset になるので、個別に判定して除去する必要がある $url = preg_replace('/#\z/u', '', $url);