add phpcs Checks and lint
This commit is contained in:
parent
9f04bf5943
commit
be4a46527a
6 changed files with 65 additions and 27 deletions
|
|
@ -85,21 +85,23 @@ class CustomHtmlErrorRenderer extends AbstractErrorRenderer
|
|||
public function renderHtmlBody(string $title = '', string $html = ''): string
|
||||
{
|
||||
return sprintf(
|
||||
'<html>' .
|
||||
' <head>' .
|
||||
" <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
|
||||
' <title>%s</title>' .
|
||||
' <style>' .
|
||||
' body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif}' .
|
||||
' h1{margin:0;font-size:48px;font-weight:normal;line-height:48px}' .
|
||||
' strong{display:inline-block;width:65px}' .
|
||||
' </style>' .
|
||||
' </head>' .
|
||||
' <body>' .
|
||||
' <h1>%s</h1>' .
|
||||
' <div>%s</div>' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
<<<HTML
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
||||
<title>%s</title>
|
||||
<style>
|
||||
body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif}
|
||||
h1{margin:0;font-size:48px;font-weight:normal;line-height:48px}
|
||||
strong{display:inline-block;width:65px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>%s</h1>
|
||||
<div>%s</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML,
|
||||
$title,
|
||||
$title,
|
||||
$html
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
33
phpcs.xml
Normal file
33
phpcs.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset name="RealWorld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||
<!-- <arg name="basepath" value="./"/> -->
|
||||
<arg name="colors"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="tab-width" value="2"/>
|
||||
<file>app/</file>
|
||||
<file>public/</file>
|
||||
<rule ref="PSR1"/>
|
||||
<rule ref="PSR2"/>
|
||||
<rule ref="PSR12"/>
|
||||
<rule ref="PSR2">
|
||||
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
|
||||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent"/>
|
||||
</rule>
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||
<properties>
|
||||
<property name="indent" value="2"/>
|
||||
<property name="tabIndent" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration">
|
||||
<properties>
|
||||
<property name="indent" value="2" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="PSR2.Methods.FunctionCallSignature">
|
||||
<properties>
|
||||
<property name="indent" value="2" />
|
||||
</properties>
|
||||
</rule>
|
||||
<arg name="tab-width" value="4"/>
|
||||
</ruleset>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../app/helpers.php';
|
||||
|
||||
use App\Kernel;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue