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

Commit d53c37c

Browse files
committed
Refactor code style for consistency by adding spaces in function declarations and control structures
1 parent e67c0ff commit d53c37c

File tree

4 files changed

+166
-122
lines changed

4 files changed

+166
-122
lines changed

src/Database/Connection.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Connection
3232
*
3333
* @return void
3434
*/
35-
static function connect()
35+
static function connect ()
3636
{
3737
// Set connection parameters from environment variables
3838
static::$port = getenv('DB_PORT') ?: 3306;
@@ -44,11 +44,11 @@ static function connect()
4444

4545
// Construct DSN (Data Source Name) for the database connection
4646
DB::$dsn = sprintf(
47-
'%s:host=%s;port=%s;dbname=%s',
48-
static::$db_type,
49-
static::$host,
50-
static::$port,
51-
static::$db_name
47+
'%s:host=%s;port=%s;dbname=%s',
48+
static::$db_type,
49+
static::$host,
50+
static::$port,
51+
static::$db_name
5252
);
5353

5454
// Set the user and password for the database connection
@@ -65,18 +65,18 @@ static function connect()
6565
*
6666
* @return void
6767
*/
68-
static function reconnect()
68+
static function reconnect ()
6969
{
7070
// Disconnect the current database connection
7171
DB::disconnect();
7272

7373
// Recreate the DSN and reconnect with the new parameters
7474
DB::$dsn = sprintf(
75-
'%s:host=%s;port=%s;dbname=%s',
76-
static::$db_type,
77-
static::$host,
78-
static::$port,
79-
static::$db_name
75+
'%s:host=%s;port=%s;dbname=%s',
76+
static::$db_type,
77+
static::$host,
78+
static::$port,
79+
static::$db_name
8080
);
8181
}
8282

@@ -89,10 +89,10 @@ static function reconnect()
8989
*
9090
* @return void
9191
*/
92-
static function init()
92+
static function init ()
9393
{
9494
DB::$host = static::$host ?? getenv('DB_HOST') ?: 3306;
9595
DB::$user = static::$user ?? getenv('DB_USER') ?: 'root';
9696
DB::$password = static::$password ?? getenv('DB_PASS') ?: '';
9797
}
98-
}
98+
}

src/Database/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract class Database extends MeekroORM
2929
* table. It ensures that the class is configured for ORM operations,
3030
* including setting up the table name.
3131
*/
32-
public function __construct()
32+
public function __construct ()
3333
{
3434
static::static();
3535
}

src/Forgery/Database.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ abstract class Database extends DB_ORM
2626
*
2727
* @param string $db_name The name of the database to be created.
2828
*/
29-
protected static function createDB($db_name)
29+
protected static function createDB ($db_name)
3030
{
31-
try {
31+
try
32+
{
3233
// Initialize database connection
3334
Connection::init();
3435

@@ -39,11 +40,14 @@ protected static function createDB($db_name)
3940
);
4041

4142
// If the database does not exist, create it
42-
if (empty($query)) {
43-
DB::query("CREATE DATABASE $db_name");
43+
if (empty($query))
44+
{
45+
DB::query("CREATE DATABASE %b", $db_name);
4446
static::log('INFO', "Created Database `$db_name`");
4547
}
46-
} catch (\Exception $e) {
48+
}
49+
catch ( \Exception $e )
50+
{
4751
// Log any exceptions that occur during the database creation
4852
static::log(
4953
'ERROR',
@@ -60,9 +64,10 @@ protected static function createDB($db_name)
6064
*
6165
* @param string $db_name The name of the database to be dropped.
6266
*/
63-
protected static function dropDB($db_name)
67+
protected static function dropDB ($db_name)
6468
{
65-
try {
69+
try
70+
{
6671
// Initialize database connection
6772
Connection::init();
6873

@@ -73,7 +78,8 @@ protected static function dropDB($db_name)
7378
);
7479

7580
// If the database does not exist, log a warning
76-
if (empty($query)) {
81+
if (empty($query))
82+
{
7783
static::log(
7884
'WARNING',
7985
"Cannot drop unexisting database `$db_name`"
@@ -82,9 +88,11 @@ protected static function dropDB($db_name)
8288
}
8389

8490
// Drop the database
85-
DB::query("DROP DATABASE $db_name");
91+
DB::query("DROP DATABASE %b", $db_name);
8692
static::log('INFO', "Dropped Database `$db_name`.");
87-
} catch (\Exception $e) {
93+
}
94+
catch ( \Exception $e )
95+
{
8896
// Log any exceptions that occur during the database drop
8997
static::log(
9098
'ERROR',
@@ -102,9 +110,10 @@ protected static function dropDB($db_name)
102110
* @param string $db_name The name of the database containing the table.
103111
* @param string $db_table The name of the table to be dropped.
104112
*/
105-
protected static function dropTable($db_name, $db_table)
113+
protected static function dropTable ($db_name, $db_table)
106114
{
107-
try {
115+
try
116+
{
108117
// Initialize database connection
109118
Connection::init();
110119

@@ -116,7 +125,8 @@ protected static function dropTable($db_name, $db_table)
116125
);
117126

118127
// If the table does not exist, log a warning
119-
if (empty($query)) {
128+
if (empty($query))
129+
{
120130
static::log(
121131
'WARNING',
122132
"Cannot drop unexisting table `$db_table` in `$db_name` Database"
@@ -125,12 +135,14 @@ protected static function dropTable($db_name, $db_table)
125135
}
126136

127137
// Drop the table
128-
DB::query("DROP TABLE $db_table");
138+
DB::query("DROP TABLE %b.%b", $db_name, $db_table);
129139
static::log(
130140
'INFO',
131141
"Dropped Table `$db_table` in `$db_name` Database."
132142
);
133-
} catch (\Exception $e) {
143+
}
144+
catch ( \Exception $e )
145+
{
134146
// Log any exceptions that occur during the table drop
135147
static::log(
136148
'ERROR',

0 commit comments

Comments
 (0)