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