From 6d1466901a32db232d6f331723b9c3a35d691ef6 Mon Sep 17 00:00:00 2001 From: Angger Pradana Date: Sat, 18 May 2024 11:19:35 +0700 Subject: [PATCH] refactor: `Karnel::class` (console and http) required `Application::class` instead of `Container::class` (#328) --- src/System/Integrate/Console/Karnel.php | 11 ++++------- src/System/Integrate/Http/Karnel.php | 16 ++++++---------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/System/Integrate/Console/Karnel.php b/src/System/Integrate/Console/Karnel.php index ccf7807b..6dfa480d 100644 --- a/src/System/Integrate/Console/Karnel.php +++ b/src/System/Integrate/Console/Karnel.php @@ -5,21 +5,18 @@ namespace System\Integrate\Console; use System\Console\Style\Style; -use System\Container\Container; +use System\Integrate\Application; class Karnel { - /** @var Container */ - protected $app; + protected Application $app; /** @var int concole exit status */ protected $exit_code; /** * Set instance. - * - * @param Container $app Application container - * */ - public function __construct(Container $app) + */ + public function __construct(Application $app) { $this->app = $app; } diff --git a/src/System/Integrate/Http/Karnel.php b/src/System/Integrate/Http/Karnel.php index df27274a..ac44acd3 100644 --- a/src/System/Integrate/Http/Karnel.php +++ b/src/System/Integrate/Http/Karnel.php @@ -4,17 +4,16 @@ namespace System\Integrate\Http; -use System\Container\Container; use System\Http\Request; use System\Http\Response; +use System\Integrate\Application; use System\Integrate\Exceptions\Handler; use System\Integrate\Http\Middleware\MaintenanceMiddleware; use System\Router\Router; class Karnel { - /** @var Container */ - protected $app; + protected Application $app; /** @var array Global middleware */ protected $middleware = [ @@ -26,10 +25,8 @@ class Karnel /** * Set instance. - * - * @param Container $app Application container - * */ - public function __construct(Container $app) + */ + public function __construct(Application $app) { $this->app = $app; } @@ -76,9 +73,8 @@ public function terminate(Request $request, Response $response): void $this->app->call([$middleware, 'terminate'], ['request' => $request, 'response' => $response]); } } - if (method_exists($this->app, 'terminate')) { - $this->app->{'terminate'}(); - } + + $this->app->terminate(); } /**