From def0e65965c3c948430365457e0c32303ee068bc Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Thu, 25 Jan 2024 03:37:11 -0400 Subject: [PATCH] Solved Engine::class phpcs problems --- flight/Engine.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/flight/Engine.php b/flight/Engine.php index 2f9aac5..af33c86 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -1,7 +1,5 @@ middleware) > 0) { foreach ($route->middleware as $middleware) { - $middleware_object = (is_callable($middleware) === true ? $middleware : (method_exists($middleware, 'before') === true ? [ $middleware, 'before' ] : false)); + $middleware_object = (is_callable($middleware) === true + ? $middleware + : (method_exists($middleware, 'before') === true + ? [$middleware, 'before'] + : false)); if ($middleware_object === false) { continue; @@ -418,7 +422,15 @@ class Engine // process the middleware in reverse order now foreach (array_reverse($route->middleware) as $middleware) { // must be an object. No functions allowed here - $middleware_object = is_object($middleware) === true && !($middleware instanceof Closure) && method_exists($middleware, 'after') === true ? [ $middleware, 'after' ] : false; + $middleware_object = false; + + if ( + is_object($middleware) === true + && !($middleware instanceof Closure) + && method_exists($middleware, 'after') === true + ) { + $middleware_object = [$middleware, 'after']; + } // has to have the after method, otherwise just skip it if ($middleware_object === false) { @@ -474,7 +486,7 @@ class Engine ->status(500) ->write($msg) ->send(); - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart } catch (Throwable $t) { exit($msg); } @@ -608,8 +620,7 @@ class Engine ->status(404) ->write( '

404 Not Found

' . - '

The page you have requested could not be found.

' . - str_repeat(' ', 512) + '

The page you have requested could not be found.

' ) ->send(); }