Use str_contains over strpos
This commit is contained in:
parent
f4686544c4
commit
c24124a6ca
@ -5,13 +5,13 @@ namespace Aviat\AnimeClient;
|
||||
$whose = $config->get('whose_list') . "'s ";
|
||||
$lastSegment = $urlGenerator->lastSegment();
|
||||
$extraSegment = $lastSegment === 'list' ? '/list' : '';
|
||||
$hasAnime = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'anime') !== FALSE;
|
||||
$hasManga = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'manga') !== FALSE;
|
||||
$hasAnime = str_contains($GLOBALS['_SERVER']['REQUEST_URI'], 'anime');
|
||||
$hasManga = str_contains($GLOBALS['_SERVER']['REQUEST_URI'], 'manga');
|
||||
|
||||
?>
|
||||
<div id="main-nav" class="flex flex-align-end flex-wrap">
|
||||
<span class="flex-no-wrap grow-1">
|
||||
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
||||
<?php if( ! str_contains($route_path, 'collection')): ?>
|
||||
<?= $helper->a(
|
||||
$urlGenerator->defaultUrl($url_type),
|
||||
$whose . ucfirst($url_type) . ' List',
|
||||
|
@ -272,7 +272,7 @@ abstract class APIRequestBuilder {
|
||||
throw new InvalidArgumentException('Invalid HTTP method');
|
||||
}
|
||||
|
||||
$realUrl = (strpos($uri, '//') !== FALSE)
|
||||
$realUrl = (str_contains($uri, '//'))
|
||||
? $uri
|
||||
: $this->baseUrl . $uri;
|
||||
|
||||
@ -297,7 +297,7 @@ abstract class APIRequestBuilder {
|
||||
*/
|
||||
private function buildUri(): Request
|
||||
{
|
||||
$url = (strpos($this->path, '//') !== FALSE)
|
||||
$url = (str_contains($this->path, '//'))
|
||||
? $this->path
|
||||
: $this->baseUrl . $this->path;
|
||||
|
||||
@ -314,11 +314,11 @@ abstract class APIRequestBuilder {
|
||||
/**
|
||||
* Reset the class state for a new request
|
||||
*
|
||||
* @param string $url
|
||||
* @param string|null $url
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
private function resetState($url, $type = 'GET'): void
|
||||
private function resetState(?string $url, $type = 'GET'): void
|
||||
{
|
||||
$requestUrl = $url ?: $this->baseUrl;
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Controller {
|
||||
|
||||
$util = $this->container->get('util');
|
||||
$doubleFormPage = $serverParams['HTTP_REFERER'] === $this->request->getUri();
|
||||
$isLoginPage = (bool) strpos($serverParams['HTTP_REFERER'], 'login');
|
||||
$isLoginPage = str_contains($serverParams['HTTP_REFERER'], 'login');
|
||||
|
||||
// Don't attempt to set the redirect url if
|
||||
// the page is one of the form type pages,
|
||||
@ -198,9 +198,6 @@ class Controller {
|
||||
* @param HtmlView $view
|
||||
* @param string $template
|
||||
* @param array $data
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ContainerException
|
||||
* @throws NotFoundException
|
||||
* @return string
|
||||
*/
|
||||
protected function loadPartial(HtmlView $view, string $template, array $data = []): string
|
||||
@ -233,8 +230,6 @@ class Controller {
|
||||
* @param string $template
|
||||
* @param array $data
|
||||
* @return HtmlView
|
||||
* @throws ContainerException
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
protected function renderFullPage(HtmlView $view, string $template, array $data): HtmlView
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ final class Anime extends BaseController {
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
if (stripos($this->request->getHeader('content-type')[0], 'application/json') !== FALSE)
|
||||
if (str_contains($this->request->getHeader('content-type')[0], 'application/json'))
|
||||
{
|
||||
$data = Json::decode((string)$this->request->getBody());
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ final class Manga extends Controller {
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
if (stripos($this->request->getHeader('content-type')[0], 'application/json') !== FALSE)
|
||||
if (str_contains($this->request->getHeader('content-type')[0], 'application/json'))
|
||||
{
|
||||
$data = Json::decode((string)$this->request->getBody());
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ final class Picture {
|
||||
|
||||
// If it is a placeholder image, make the
|
||||
// fallback a png, not a jpg
|
||||
if (strpos($uri, 'placeholder') !== FALSE)
|
||||
if (str_contains($uri, 'placeholder'))
|
||||
{
|
||||
$fallbackExt = 'png';
|
||||
}
|
||||
|
||||
if (strpos($uri, '//') === FALSE)
|
||||
if ( ! str_contains($uri, '//'))
|
||||
{
|
||||
$uri = $urlGenerator->assetUrl($uri);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user