Code style updates

This commit is contained in:
Timothy Warren 2023-05-09 12:49:36 -04:00
parent c78bccc56d
commit 0cff220993
22 changed files with 113 additions and 157 deletions

View File

@ -189,7 +189,7 @@ final class Model
*/ */
public function deleteItem(FormItem $data, string $type): ?Request public function deleteItem(FormItem $data, string $type): ?Request
{ {
$mediaId = $this->getMediaId((array)$data, $type); $mediaId = $this->getMediaId((array) $data, $type);
if ($mediaId === NULL) if ($mediaId === NULL)
{ {
return NULL; return NULL;
@ -209,7 +209,7 @@ final class Model
*/ */
public function getListIdFromData(FormItem $data, string $type = 'ANIME'): ?string public function getListIdFromData(FormItem $data, string $type = 'ANIME'): ?string
{ {
$mediaId = $this->getMediaId((array)$data, $type); $mediaId = $this->getMediaId((array) $data, $type);
if ($mediaId === NULL) if ($mediaId === NULL)
{ {
return NULL; return NULL;
@ -244,7 +244,7 @@ final class Model
/** /**
* Find the id to update by * Find the id to update by
*/ */
private function getMediaId (array $data, string $type = 'ANIME'): ?string private function getMediaId(array $data, string $type = 'ANIME'): ?string
{ {
if (isset($data['anilist_id'])) if (isset($data['anilist_id']))
{ {

View File

@ -133,7 +133,7 @@ final class Auth
/** /**
* Save the new authentication information * Save the new authentication information
*/ */
private function storeAuth(array|FALSE $auth): bool private function storeAuth(array|false $auth): bool
{ {
if (FALSE !== $auth) if (FALSE !== $auth)
{ {

View File

@ -34,6 +34,7 @@ use Aviat\AnimeClient\API\{
use Aviat\AnimeClient\Enum\MediaType; use Aviat\AnimeClient\Enum\MediaType;
use Aviat\AnimeClient\Kitsu as K; use Aviat\AnimeClient\Kitsu as K;
use Aviat\AnimeClient\Types\{Anime, MangaPage}; use Aviat\AnimeClient\Types\{Anime, MangaPage};
use Aviat\AnimeClient\Types\{AnimeListItem, MangaListItem};
use Aviat\Ion\{ use Aviat\Ion\{
Di\ContainerAware, Di\ContainerAware,
Json Json

View File

@ -67,9 +67,6 @@ trait MutationTrait
/** /**
* Remove a list item * Remove a list item
*
* @param FormItem $data
* @return Request
*/ */
public function deleteItem(FormItem $data): Request public function deleteItem(FormItem $data): Request
{ {

View File

@ -35,7 +35,7 @@ final class ParallelAPIRequest
/** /**
* Add a request * Add a request
*/ */
public function addRequest(string|Request $request, string|int|NULL $key = NULL): self public function addRequest(string|Request $request, string|int|null $key = NULL): self
{ {
if ($key !== NULL) if ($key !== NULL)
{ {

View File

@ -17,6 +17,7 @@ namespace Aviat\AnimeClient;
use Amp\Http\Client\{HttpClient, HttpClientBuilder, Request, Response}; use Amp\Http\Client\{HttpClient, HttpClientBuilder, Request, Response};
use Aviat\Ion\{ConfigInterface, ImageBuilder}; use Aviat\Ion\{ConfigInterface, ImageBuilder};
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use Throwable; use Throwable;
@ -31,9 +32,9 @@ use function Aviat\Ion\_dir;
/** /**
* Load configuration options from .toml files * Load configuration options from .toml files
* *
* @codeCoverageIgnore
* @param string $path - Path to load config * @param string $path - Path to load config
*/ */
#[CodeCoverageIgnore]
function loadConfig(string $path): array function loadConfig(string $path): array
{ {
$output = []; $output = [];
@ -72,9 +73,8 @@ function loadConfig(string $path): array
/** /**
* Load config from one specific TOML file * Load config from one specific TOML file
*
* @codeCoverageIgnore
*/ */
#[CodeCoverageIgnore]
function loadTomlFile(string $filename): array function loadTomlFile(string $filename): array
{ {
return Toml::parseFile($filename); return Toml::parseFile($filename);
@ -131,19 +131,6 @@ function tomlToArray(string $toml): array
//! Misc Functions //! Misc Functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
if ( ! function_exists('array_is_list'))
{
/**
* Polyfill for PHP 8
*
* @see https://www.php.net/manual/en/function.array-is-list
*/
function array_is_list(array $a): bool
{
return $a === [] || (array_keys($a) === range(0, count($a) - 1));
}
}
/** /**
* Is the array sequential, not associative? * Is the array sequential, not associative?
*/ */
@ -256,9 +243,8 @@ function getLocalImg(string $kitsuUrl, bool $webp = TRUE): string
/** /**
* Create a transparent placeholder image * Create a transparent placeholder image
*
* @codeCoverageIgnore
*/ */
#[CodeCoverageIgnore]
function createPlaceholderImage(string $path, int $width = 200, int $height = 200, string $text = 'Image Unavailable'): bool function createPlaceholderImage(string $path, int $width = 200, int $height = 200, string $text = 'Image Unavailable'): bool
{ {
$img = ImageBuilder::new($width, $height) $img = ImageBuilder::new($width, $height)
@ -303,16 +289,15 @@ function clearCache(CacheInterface $cache): bool
$cleared = $cache->clear(); $cleared = $cache->clear();
$saved = (empty($userData)) ? TRUE : $cache->setMultiple($userData); $saved = empty($userData) || $cache->setMultiple($userData);
return $cleared && $saved; return $cleared && $saved;
} }
/** /**
* Render a PHP code template as a string * Render a PHP code template as a string
*
* @codeCoverageIgnore
*/ */
#[CodeCoverageIgnore]
function renderTemplate(string $path, array $data): string function renderTemplate(string $path, array $data): string
{ {
ob_start(); ob_start();

View File

@ -44,7 +44,7 @@ abstract class BaseCommand extends Command
/** /**
* Echo text in a box * Echo text in a box
*/ */
public function echoBox(string|array $message, string|int|NULL $fgColor = NULL, string|int|NULL $bgColor = NULL): void public function echoBox(string|array $message, string|int|null $fgColor = NULL, string|int|null $bgColor = NULL): void
{ {
if (is_array($message)) if (is_array($message))
{ {
@ -131,7 +131,7 @@ abstract class BaseCommand extends Command
return $this->_di($configArray, $APP_DIR); return $this->_di($configArray, $APP_DIR);
} }
private function _line(string $message, int|string|NULL $fgColor = NULL, int|string|NULL $bgColor = NULL): void private function _line(string $message, int|string|null $fgColor = NULL, int|string|null $bgColor = NULL): void
{ {
if ($fgColor !== NULL) if ($fgColor !== NULL)
{ {

View File

@ -98,21 +98,23 @@ final class SyncLists extends BaseCommand
if ( ! $anilistEnabled) if ( ! $anilistEnabled)
{ {
$this->echoErrorBox('Anlist API is not enabled. Can not sync.'); $this->echoErrorBox('Anlist API is not enabled. Can not sync.');
return false;
return FALSE;
} }
// Authentication is required to update Kitsu // Authentication is required to update Kitsu
$isKitsuAuthenticated = $this->container->get('auth')->isAuthenticated(); $isKitsuAuthenticated = $this->container->get('auth')->isAuthenticated();
if ( !$isKitsuAuthenticated) if ( ! $isKitsuAuthenticated)
{ {
$this->echoErrorBox('Kitsu is not authenticated. Kitsu list can not be updated.'); $this->echoErrorBox('Kitsu is not authenticated. Kitsu list can not be updated.');
return false;
return FALSE;
} }
$this->anilistModel = $this->container->get('anilist-model'); $this->anilistModel = $this->container->get('anilist-model');
$this->kitsuModel = $this->container->get('kitsu-model'); $this->kitsuModel = $this->container->get('kitsu-model');
return true; return TRUE;
} }
/** /**
@ -148,7 +150,7 @@ final class SyncLists extends BaseCommand
*/ */
protected function fetch(string $type): array protected function fetch(string $type): array
{ {
$this->echo("Fetching $type List Data"); $this->echo("Fetching {$type} List Data");
$progress = new Widgets\ProgressBar($this->getConsole(), 2, 50, FALSE); $progress = new Widgets\ProgressBar($this->getConsole(), 2, 50, FALSE);
$anilist = $this->fetchAnilist($type); $anilist = $this->fetchAnilist($type);

View File

@ -121,13 +121,13 @@ class Controller
} }
/** /**
* Set the current url in the session as the target of a future redirect * Set the current url in the session as the target of a future redirect
* *
* @codeCoverageIgnore * @throws ContainerException
* @throws ContainerException * @throws NotFoundException
* @throws NotFoundException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
public function setSessionRedirect(?string $url = NULL): void public function setSessionRedirect(?string $url = NULL): void
{ {
$serverParams = $this->request->getServerParams(); $serverParams = $this->request->getServerParams();
@ -159,14 +159,14 @@ class Controller
} }
/** /**
* Redirect to the url previously set in the session * Redirect to the url previously set in the session
* *
* If one is not set, redirect to default url * If one is not set, redirect to default url
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
public function sessionRedirect(): void public function sessionRedirect(): void
{ {
$target = $this->session->get('redirect_url') ?? '/'; $target = $this->session->get('redirect_url') ?? '/';
@ -175,10 +175,10 @@ class Controller
} }
/** /**
* Check if the current user is authenticated, else error and exit * Check if the current user is authenticated, else error and exit
* @codeCoverageIgnore */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
protected function checkAuth(): void protected function checkAuth(): void
{ {
if ( ! $this->auth->isAuthenticated()) if ( ! $this->auth->isAuthenticated())
{ {
@ -191,11 +191,10 @@ class Controller
} }
/** /**
* Get the string output of a partial template * Get the string output of a partial template
* */
* @codeCoverageIgnore #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
*/ protected function loadPartial(HtmlView $view, string $template, array $data = []): string
protected function loadPartial(HtmlView $view, string $template, array $data = []): string
{ {
$router = $this->container->get('dispatcher'); $router = $this->container->get('dispatcher');
@ -218,11 +217,10 @@ class Controller
} }
/** /**
* Render a template with header and footer * Render a template with header and footer
* */
* @codeCoverageIgnore #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
*/ protected function renderFullPage(HtmlView $view, string $template, array $data): HtmlView
protected function renderFullPage(HtmlView $view, string $template, array $data): HtmlView
{ {
$csp = [ $csp = [
"default-src 'self' media.kitsu.io kitsu-production-media.s3.us-west-002.backblazeb2.com", "default-src 'self' media.kitsu.io kitsu-production-media.s3.us-west-002.backblazeb2.com",
@ -245,12 +243,12 @@ class Controller
} }
/** /**
* 404 action * 404 action
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
public function notFound( public function notFound(
string $title = 'Sorry, page not found', string $title = 'Sorry, page not found',
string $message = 'Page Not Found' string $message = 'Page Not Found'
): void { ): void {
@ -263,12 +261,12 @@ class Controller
} }
/** /**
* Display a generic error page * Display a generic error page
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
public function errorPage(int $httpCode, string $title, string $message, string $longMessage = ''): void public function errorPage(int $httpCode, string $title, string $message, string $longMessage = ''): void
{ {
$this->outputHTML('error', [ $this->outputHTML('error', [
'title' => $title, 'title' => $title,
@ -278,24 +276,23 @@ class Controller
} }
/** /**
* Redirect to the default controller/url from an empty path * Redirect to the default controller/url from an empty path
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
public function redirectToDefaultRoute(): void public function redirectToDefaultRoute(): void
{ {
$defaultType = $this->config->get('default_list'); $defaultType = $this->config->get('default_list');
$this->redirect($this->urlGenerator->defaultUrl($defaultType), 303); $this->redirect($this->urlGenerator->defaultUrl($defaultType), 303);
} }
/** /**
* Set a session flash variable to display a message on * Set a session flash variable to display a message on
* next page load * next page load
* */
* @codeCoverageIgnore #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
*/ public function setFlashMessage(string $message, string $type = 'info'): void
public function setFlashMessage(string $message, string $type = 'info'): void
{ {
static $messages; static $messages;
@ -323,12 +320,12 @@ class Controller
} }
/** /**
* Add a message box to the page * Add a message box to the page
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
protected function showMessage(HtmlView $view, string $type, string $message): string protected function showMessage(HtmlView $view, string $type, string $message): string
{ {
return $this->loadPartial($view, 'message', [ return $this->loadPartial($view, 'message', [
'message_type' => $type, 'message_type' => $type,
@ -337,12 +334,12 @@ class Controller
} }
/** /**
* Output a template to HTML, using the provided data * Output a template to HTML, using the provided data
* *
* @codeCoverageIgnore * @throws InvalidArgumentException
* @throws InvalidArgumentException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
protected function outputHTML(string $template, array $data = [], ?HtmlView $view = NULL, int $code = 200): void protected function outputHTML(string $template, array $data = [], ?HtmlView $view = NULL, int $code = 200): void
{ {
if (NULL === $view) if (NULL === $view)
{ {
@ -354,13 +351,13 @@ class Controller
} }
/** /**
* Output a JSON Response * Output a JSON Response
* *
* @codeCoverageIgnore * @param int $code - the http status code
* @param int $code - the http status code * @throws DoubleRenderException
* @throws DoubleRenderException */
*/ #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
protected function outputJSON(mixed $data, int $code): void protected function outputJSON(mixed $data, int $code): void
{ {
JsonView::new() JsonView::new()
->setOutput($data) ->setOutput($data)
@ -369,11 +366,10 @@ class Controller
} }
/** /**
* Redirect to the selected page * Redirect to the selected page
* */
* @codeCoverageIgnore #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
*/ protected function redirect(string $url, int $code): void
protected function redirect(string $url, int $code): void
{ {
HttpView::new() HttpView::new()
->redirect($url, $code) ->redirect($url, $code)

View File

@ -21,8 +21,7 @@ use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\Anime as AnimeModel; use Aviat\AnimeClient\Model\Anime as AnimeModel;
use Aviat\AnimeClient\Types\FormItem; use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
use Aviat\Ion\Json; use Aviat\Ion\Json;

View File

@ -20,11 +20,9 @@ use Aviat\AnimeClient\Model\{
Anime as AnimeModel, Anime as AnimeModel,
AnimeCollection as AnimeCollectionModel AnimeCollection as AnimeCollectionModel
}; };
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
use Aviat\Ion\Json;
use Aviat\Ion\Exception\DoubleRenderException; use Aviat\Ion\Exception\DoubleRenderException;
use InvalidArgumentException; use InvalidArgumentException;
@ -114,7 +112,6 @@ final class AnimeCollection extends BaseController
/** /**
* Show the anime collection add/edit form * Show the anime collection add/edit form
* *
* @param int|null $id
* @throws ContainerException * @throws ContainerException
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws NotFoundException * @throws NotFoundException

View File

@ -18,8 +18,7 @@ use Aviat\AnimeClient\API\Kitsu\Model;
use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};

View File

@ -14,9 +14,8 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aviat\Ion\Attribute\Controller;
use Aviat\Ion\Attribute\Route;
use Aviat\AnimeClient\{Controller as BaseController, Model}; use Aviat\AnimeClient\{Controller as BaseController, Model};
use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};

View File

@ -15,8 +15,7 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Throwable; use Throwable;
use function Amp\Promise\wait; use function Amp\Promise\wait;
use function Aviat\AnimeClient\{createPlaceholderImage, getResponse}; use function Aviat\AnimeClient\{createPlaceholderImage, getResponse};

View File

@ -14,21 +14,16 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aura\Router\Exception\RouteNotFound;
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
use Aviat\AnimeClient\API\Mapping\MangaReadingStatus; use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\Manga as MangaModel; use Aviat\AnimeClient\Model\Manga as MangaModel;
use Aviat\AnimeClient\Types\FormItem; use Aviat\AnimeClient\Types\FormItem;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};
use Aviat\Ion\Json; use Aviat\Ion\Json;
use InvalidArgumentException;
use Throwable;
/** /**
* Controller for manga list * Controller for manga list
*/ */

View File

@ -15,12 +15,10 @@
namespace Aviat\AnimeClient\Controller; namespace Aviat\AnimeClient\Controller;
use Aviat\AnimeClient\API\Kitsu\Model; use Aviat\AnimeClient\API\Kitsu\Model;
use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\{CharacterTransformer, PersonTransformer};
use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Enum\EventType; use Aviat\AnimeClient\Enum\EventType;
use Aviat\Ion\Attribute\DefaultController; use Aviat\Ion\Attribute\{DefaultController, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Event; use Aviat\Ion\Event;
use Aviat\Ion\View\HtmlView; use Aviat\Ion\View\HtmlView;

View File

@ -18,8 +18,7 @@ use Aviat\AnimeClient\API\Kitsu\Model;
use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};

View File

@ -18,8 +18,7 @@ use Aura\Router\Exception\RouteNotFound;
use Aviat\AnimeClient\API\Anilist\Model as AnilistModel; use Aviat\AnimeClient\API\Anilist\Model as AnilistModel;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\Model\Settings as SettingsModel; use Aviat\AnimeClient\Model\Settings as SettingsModel;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};

View File

@ -18,8 +18,7 @@ use Aviat\AnimeClient\API\Kitsu\Model;
use Aviat\AnimeClient\API\Kitsu\Transformer\UserTransformer; use Aviat\AnimeClient\API\Kitsu\Transformer\UserTransformer;
use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\Controller as BaseController;
use Aviat\Ion\Attribute\Controller; use Aviat\Ion\Attribute\{Controller, Route};
use Aviat\Ion\Attribute\Route;
use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Di\ContainerInterface;
use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException}; use Aviat\Ion\Di\Exception\{ContainerException, NotFoundException};

View File

@ -317,14 +317,15 @@ final class Dispatcher extends RoutingBase
$params = []; $params = [];
switch ($failure->failedRule) { switch ($failure->failedRule)
{
case Rule\Allows::class: case Rule\Allows::class:
$params = [ $params = [
'http_code' => 405, 'http_code' => 405,
'title' => '405 Method Not Allowed', 'title' => '405 Method Not Allowed',
'message' => 'Invalid HTTP Verb', 'message' => 'Invalid HTTP Verb',
]; ];
break; break;
case Rule\Accepts::class: case Rule\Accepts::class:
$params = [ $params = [
@ -332,12 +333,12 @@ final class Dispatcher extends RoutingBase
'title' => '406 Not Acceptable', 'title' => '406 Not Acceptable',
'message' => 'Unacceptable content type', 'message' => 'Unacceptable content type',
]; ];
break; break;
default: default:
// Fall back to a 404 message // Fall back to a 404 message
$actionMethod = NOT_FOUND_METHOD; $actionMethod = NOT_FOUND_METHOD;
break; break;
} }
return [ return [

View File

@ -95,14 +95,7 @@ final class Settings
} }
} }
if (array_key_exists($key, $values) && is_scalar($values[$key])) $value['value'] = array_key_exists($key, $values) && is_scalar($values[$key]) ? $values[$key] : $value['default'] ?? '';
{
$value['value'] = $values[$key];
}
else
{
$value['value'] = $value['default'] ?? '';
}
foreach (['readonly', 'disabled'] as $flag) foreach (['readonly', 'disabled'] as $flag)
{ {

View File

@ -201,10 +201,8 @@ abstract class AbstractType implements ArrayAccess, Countable, Stringable
return TRUE; return TRUE;
} }
/** #[\PHPUnit\Framework\Attributes\CodeCoverageIgnore]
* @codeCoverageIgnore final protected function fromObject(mixed $parent = NULL): float|null|bool|int|array|string
*/
final protected function fromObject(mixed $parent = NULL): float|NULL|bool|int|array|string
{ {
$object = $parent ?? $this; $object = $parent ?? $this;