Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 1bdf0e7

Browse files
committed
Refactor Application class: improve code readability by adjusting formatting, enhancing consistency in method definitions, and updating PHPSLIDES_VERSION to 1.4.3.
1 parent 026efc4 commit 1bdf0e7

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

src/Foundation/Application.php

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ class Application extends Controller implements ApplicationInterface
3131
{
3232
use Configuration;
3333
use Logger;
34-
use DBLogger {
35-
Logger::log insteadof DBLogger;
36-
DBLogger::log as db_log;
34+
use DBLogger
35+
{
36+
Logger::log insteadof DBLogger;
37+
DBLogger::log as db_log;
3738
}
3839

3940
/**
4041
* The version of the PhpSlides application.
4142
*/
42-
public const PHPSLIDES_VERSION = '1.4.4';
43+
public const PHPSLIDES_VERSION = '1.4.3';
4344

4445
/**
4546
* @var string $REMOTE_ADDR The remote address of the client making the request.
@@ -95,27 +96,30 @@ class Application extends Controller implements ApplicationInterface
9596
*
9697
* @return self Returns an instance of the Application class.
9798
*/
98-
private static function configure(): void
99+
private static function configure (): void
99100
{
100-
if (php_sapi_name() == 'cli-server') {
101+
if (php_sapi_name() == 'cli-server')
102+
{
101103
self::$request_uri = urldecode(
102-
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),
104+
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),
103105
);
104106
self::$basePath = '';
105-
} else {
107+
}
108+
else
109+
{
106110
self::$request_uri = urldecode(
107-
parse_url(
108-
$_REQUEST['uri'] ?? $_SERVER['REQUEST_URI'],
109-
PHP_URL_PATH,
110-
),
111+
parse_url(
112+
$_REQUEST['uri'] ?? $_SERVER['REQUEST_URI'],
113+
PHP_URL_PATH,
114+
),
111115
);
112116

113117
$find = '/src/routes/render.php';
114118
$self = $_SERVER['PHP_SELF'];
115119

116120
self::$basePath = strrpos($self, $find)
117-
? substr_replace($self, '/', strrpos($self, $find), strlen($find))
118-
: '../../';
121+
? substr_replace($self, '/', strrpos($self, $find), strlen($find))
122+
: '../../';
119123
}
120124

121125
$req = new Request();
@@ -129,7 +133,7 @@ private static function configure(): void
129133
*
130134
* @return void
131135
*/
132-
private static function paths(): void
136+
private static function paths (): void
133137
{
134138
self::$configsDir = self::$basePath . 'src/configs/';
135139
self::$viewsDir = self::$basePath . 'src/resources/views/';
@@ -142,15 +146,15 @@ private static function paths(): void
142146
*
143147
* @return void
144148
*/
145-
public function create(): void
149+
public function create (): void
146150
{
147151
self::configure();
148152
self::paths();
149153

150154
$loader = new FileLoader();
151155
$loader
152-
->load(__DIR__ . '/../Config/env.config.php')
153-
->load(__DIR__ . '/../Config/config.php');
156+
->load(__DIR__ . '/../Config/env.config.php')
157+
->load(__DIR__ . '/../Config/config.php');
154158

155159
session_start();
156160

@@ -159,9 +163,11 @@ public function create(): void
159163

160164
$sid = session_id();
161165

162-
if (getenv('HOT_RELOAD') == 'true') {
163-
Route::post("/hot-reload-a$sid", fn() => (new HotReload())->reload());
164-
Route::get("/hot-reload-a$sid/worker", function () use ($sid): string {
166+
if (getenv('HOT_RELOAD') == 'true')
167+
{
168+
Route::post("/hot-reload-a$sid", fn () => (new HotReload())->reload());
169+
Route::get("/hot-reload-a$sid/worker", function () use ($sid): string
170+
{
165171
$addr = self::$REMOTE_ADDR . "/hot-reload-a$sid";
166172
header('Content-Type: application/javascript');
167173

@@ -170,18 +176,22 @@ public function create(): void
170176
Render::WebRoute();
171177
}
172178

173-
try {
179+
try
180+
{
174181
Connection::init();
175182
DB::query('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA');
176-
} catch (\Exception $e) {
183+
}
184+
catch ( \Exception $e )
185+
{
177186
Database::$_connect_error = $e->getMessage();
178187
goto EXECUTION;
179188
}
180189
new Forge();
181190
new Autoloader();
182191

183192
EXECUTION:
184-
try {
193+
try
194+
{
185195
$loader->load(__DIR__ . '/../Globals/Functions.php');
186196

187197
$config_file = self::config_file();
@@ -191,11 +201,14 @@ public function create(): void
191201
header("Content-Type: text/html; charset=$charset");
192202

193203
self::config();
194-
} catch (\Exception $e) {
204+
}
205+
catch ( \Exception $e )
206+
{
195207
http_response_code(500);
196208
static::log();
197209

198-
if (function_exists('ExceptionHandler')) {
210+
if (function_exists('ExceptionHandler'))
211+
{
199212
call_user_func('ExceptionHandler', $e);
200213
}
201214
}

0 commit comments

Comments
 (0)