非推奨のヘルパ関数の利用をやめる
This commit is contained in:
parent
a48fe596e1
commit
74fee83f4e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class CsvImportException extends \RuntimeException
|
class CsvImportException extends \RuntimeException
|
||||||
@ -15,7 +16,7 @@ class CsvImportException extends \RuntimeException
|
|||||||
*/
|
*/
|
||||||
public function __construct(...$errors)
|
public function __construct(...$errors)
|
||||||
{
|
{
|
||||||
parent::__construct(array_first($errors));
|
parent::__construct(Arr::first($errors));
|
||||||
$this->errors = $errors;
|
$this->errors = $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\MetadataResolver;
|
namespace App\MetadataResolver;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
|
|
||||||
class NijieResolver implements Resolver
|
class NijieResolver implements Resolver
|
||||||
@ -50,8 +51,8 @@ class NijieResolver implements Resolver
|
|||||||
$metadata->description = '投稿者: ' . $data['author']['name'] . PHP_EOL . $data['description'];
|
$metadata->description = '投稿者: ' . $data['author']['name'] . PHP_EOL . $data['description'];
|
||||||
if (
|
if (
|
||||||
isset($data['thumbnailUrl']) &&
|
isset($data['thumbnailUrl']) &&
|
||||||
!ends_with($data['thumbnailUrl'], '.gif') &&
|
!Str::endsWith($data['thumbnailUrl'], '.gif') &&
|
||||||
!ends_with($data['thumbnailUrl'], '.mp4')
|
!Str::endsWith($data['thumbnailUrl'], '.mp4')
|
||||||
) {
|
) {
|
||||||
// サムネイルからメイン画像に
|
// サムネイルからメイン画像に
|
||||||
$metadata->image = str_replace('__rs_l160x160/', '', $data['thumbnailUrl']);
|
$metadata->image = str_replace('__rs_l160x160/', '', $data['thumbnailUrl']);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Utilities;
|
namespace App\Utilities;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Misd\Linkify\Linkify;
|
use Misd\Linkify\Linkify;
|
||||||
|
|
||||||
class Formatter
|
class Formatter
|
||||||
@ -55,10 +56,10 @@ class Formatter
|
|||||||
$parts = parse_url($url);
|
$parts = parse_url($url);
|
||||||
if (!empty($parts['query'])) {
|
if (!empty($parts['query'])) {
|
||||||
// Remove query parameters
|
// Remove query parameters
|
||||||
$url = str_replace_last('?' . $parts['query'], '', $url);
|
$url = Str::replaceFirst('?' . $parts['query'], '', $url);
|
||||||
if (!empty($parts['fragment'])) {
|
if (!empty($parts['fragment'])) {
|
||||||
// Remove fragment identifier
|
// Remove fragment identifier
|
||||||
$url = str_replace_last('#' . $parts['fragment'], '', $url);
|
$url = Str::replaceFirst('#' . $parts['fragment'], '', $url);
|
||||||
} else {
|
} else {
|
||||||
// "http://example.com/?query#" の場合 $parts['fragment'] は unset になるので、個別に判定して除去する必要がある
|
// "http://example.com/?query#" の場合 $parts['fragment'] は unset になるので、個別に判定して除去する必要がある
|
||||||
$url = preg_replace('/#\z/u', '', $url);
|
$url = preg_replace('/#\z/u', '', $url);
|
||||||
|
Loading…
Reference in New Issue
Block a user