diff --git a/app/ErrorHandler/CustomHtmlErrorRenderer.php b/app/ErrorHandler/CustomHtmlErrorRenderer.php index c2238aa..16af79b 100644 --- a/app/ErrorHandler/CustomHtmlErrorRenderer.php +++ b/app/ErrorHandler/CustomHtmlErrorRenderer.php @@ -85,21 +85,23 @@ class CustomHtmlErrorRenderer extends AbstractErrorRenderer public function renderHtmlBody(string $title = '', string $html = ''): string { return sprintf( - '' . - ' ' . - " " . - ' %s' . - ' ' . - ' ' . - ' ' . - '

%s

' . - '
%s
' . - ' ' . - '', + << + + + %s + + + +

%s

+
%s
+ + + HTML, $title, $title, $html diff --git a/app/Kernel.php b/app/Kernel.php index afda506..f6a52f1 100644 --- a/app/Kernel.php +++ b/app/Kernel.php @@ -8,14 +8,12 @@ use Dotenv\Dotenv; use Dotenv\Exception\InvalidPathException; use Slim\Factory\AppFactory; -require_once __DIR__ . '/helpers.php'; - class Kernel { private static $app; private static $env; - private static function _build() + private static function build() { self::$app = AppFactory::create(); @@ -34,7 +32,7 @@ class Kernel // Add Routing Middleware self::$app->addRoutingMiddleware(); - self::$app->add(new ThrottleMiddleware); + self::$app->add(new ThrottleMiddleware()); /** * Add Error Handling Middleware @@ -79,21 +77,24 @@ class Kernel } switch (strtolower($value)) { - case 'true': case '(true)': - return true; + $value = true; + break; case 'false': case '(false)': - return false; + $value = false; + break; case 'empty': case '(empty)': - return ''; + $value = ''; + break; case 'null': case '(null)': - return; + $value = null; + break; } return $value; @@ -101,7 +102,7 @@ class Kernel public static function run() { - self::_build(); + self::build(); self::$app->run(); } } diff --git a/app/Middlewares/ThrottleMiddleware.php b/app/Middlewares/ThrottleMiddleware.php index 5dc8384..6216e2a 100644 --- a/app/Middlewares/ThrottleMiddleware.php +++ b/app/Middlewares/ThrottleMiddleware.php @@ -20,7 +20,7 @@ class ThrottleMiddleware */ public function __invoke(Request $request, RequestHandler $handler): Response { - $throttle = new LeakyBucket; + $throttle = new LeakyBucket(); //! Enable APC in Laragon https://forum.laragon.org/topic/1245/regarding-caching-plugin-availability/4 $storage = new \Stiphle\Storage\Apcu(); $throttle->setStorage($storage); diff --git a/app/Routes/web.php b/app/Routes/web.php index 82a4e7c..8ebe278 100644 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -6,7 +6,8 @@ use jucksearm\barcode\Datamatrix; Kernel::app()->get('/{code}', function ($request, $response, $args) { $s = intval($request->getQueryParams()['s'] ?? 300); $s = is_int($s) ? $s : 300; - $s = $s <= env('MinPixSize', 60) ? env('MinPixSize', 60) : ($s >= env('MaxPixSize', 2000) ? env('MaxPixSize', 2000) : $s); + $s = $s <= env('MinPixSize', 60) ? + env('MinPixSize', 60) : ($s >= env('MaxPixSize', 2000) ? env('MaxPixSize', 2000) : $s); $m = round(20 * 2 / 300); $m = $m <= 5 ? 5 : ($m >= 300 ? 300 : $m); $image = @Datamatrix::factory() diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..a852cef --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,33 @@ + + + + + + + app/ + public/ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/index.php b/public/index.php index 70d02cf..d58c17c 100644 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,7 @@