Refactor Classes
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<?php /** @noinspection PhpUndefinedClassInspection */
|
||||
<?php
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Middleware;
|
||||
|
||||
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -14,12 +16,15 @@ use Throwable;
|
||||
|
||||
class ErrorHandler
|
||||
{
|
||||
/**
|
||||
* @var App<ContainerInterface>
|
||||
*/
|
||||
protected App $app;
|
||||
|
||||
/**
|
||||
* ErrorHandler constructor.
|
||||
*
|
||||
* @param App $app
|
||||
* @param App<ContainerInterface> $app
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
@@ -29,7 +34,7 @@ class ErrorHandler
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return mixed[]
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'timestamp' => "false|string",
|
||||
@@ -71,8 +76,7 @@ class ErrorHandler
|
||||
bool $logErrors,
|
||||
bool $logErrorDetails,
|
||||
?LoggerInterface $logger = null
|
||||
): ResponseInterface
|
||||
{
|
||||
): ResponseInterface {
|
||||
if ($logger !== null && $logErrors === true) {
|
||||
$logger->error($exception->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user