非推奨のヘルパ関数の利用をやめる

This commit is contained in:
shibafu 2020-05-23 22:26:47 +09:00
parent a48fe596e1
commit 74fee83f4e
3 changed files with 8 additions and 5 deletions

View File

@ -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;
}

View File

@ -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']);

View File

@ -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);