Skip to content

Commit f58d404

Browse files
author
Fredrick Peter
committed
All response name, changed to same status
1 parent a8e3379 commit f58d404

File tree

9 files changed

+41
-43
lines changed

9 files changed

+41
-43
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,12 +1223,12 @@ use builder\Database\DBImport;
12231223
$import = new DBImport();
12241224
12251225
// needs absolute path to database file
1226-
$response = $import->DatabaseImport('orm.sql');
1226+
$status = $import->DatabaseImport('orm.sql');
12271227
12281228
- Status code
1229-
->response == 404 (Failed to read file or File does'nt exists
1230-
->response == 400 (Query to database error
1231-
->response == 200 (Success importing to database
1229+
->status == 404 (Failed to read file or File does'nt exists
1230+
->status == 400 (Query to database error
1231+
->status == 200 (Success importing to database
12321232
```
12331233

12341234
- or -- `Helpers Function`

src/AutoloadEnv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static public function start(?array $options = [])
9595
| Error on using the Database model
9696
|
9797
*/
98-
if($loader['response'] != 200){
98+
if($loader['status'] != 200){
9999
/**
100100
* Setting application to use the dump error handling
101101
*/

src/DBImport.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ public function DatabaseImport($path_to_sql = NULL)
105105

106106
/*
107107
| ----------------------------------------------------------------------------
108-
| Database importation use. Below are the response code
108+
| Database importation use. Below are the status code
109109
| ----------------------------------------------------------------------------
110-
| if ->response === 404 (Failed to read file or File does'nt exists
111-
| if ->response === 400 (Query to database error
112-
| if ->response === 200 (Success importing to database
110+
| if ->status === 404 (Failed to read file or File does'nt exists
111+
| if ->status === 400 (Query to database error
112+
| if ->status === 200 (Success importing to database
113113
*/
114114

115115
return (object) [
116-
'response' => $this->error,
117-
'message' => is_array($this->message)
116+
'status' => $this->error,
117+
'message' => is_array($this->message)
118118
? implode('\n<br>', $this->message)
119119
: $this->message
120120
];

src/Migrations/Blueprint.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ private function MySQLTemplate()
6464
$checkPrimary = array_column($this->columns, 'primary');
6565
if(count($checkPrimary) > 1){
6666
return [
67-
'response' => self::ERROR_404,
67+
'status' => self::ERROR_404,
6868
'message' => sprintf("Primary Key can not be more than one in `%s` @table", $this->tableName),
6969
];
7070
}
7171

7272
return [
73-
'response' => self::ERROR_200,
73+
'status' => self::ERROR_200,
7474
'message' => $this->toMySQLQuery()
7575
];
7676
}
@@ -86,14 +86,14 @@ public function handle()
8686
$traceTable = $this->traceable($this->tableName);
8787

8888
// handle error
89-
$handle = self::checkDBConnect($traceTable);
89+
$handle = self::checkDBConnect();
9090
if(is_array($handle)){
9191
return $handle;
9292
}
9393

9494
// primary key error
9595
$mysqlHandle = $this->MySQLTemplate();
96-
if($mysqlHandle['response'] != self::ERROR_200){
96+
if($mysqlHandle['status'] != self::ERROR_200){
9797
return $mysqlHandle;
9898
}
9999

@@ -120,11 +120,11 @@ public function handle()
120120
}
121121

122122
return [
123-
'response' => self::ERROR_200,
123+
'status' => self::ERROR_200,
124124
'message' => $message,
125125
];
126126
} catch (PDOException $e){
127-
return ['response' => self::ERROR_404, 'message' => $e->getMessage()];
127+
return ['status' => self::ERROR_404, 'message' => $e->getMessage()];
128128
}
129129
}
130130

@@ -140,11 +140,10 @@ public function __destruct()
140140

141141
/**
142142
* Check database connection error
143-
* @param string $tableName
144143
*
145144
* @return mixed
146145
*/
147-
private function checkDBConnect(?string $tableName = null)
146+
private function checkDBConnect()
148147
{
149148
// if database connection is okay
150149
$dbConnection = $this->db->getConnection();
@@ -154,7 +153,7 @@ private function checkDBConnect(?string $tableName = null)
154153
'message' => "Connection Error
155154
<span style='background: #ee0707; {$this->style}'>
156155
Database Connection Error
157-
</span> on `{$tableName}`
156+
</span>
158157
`{$dbConnection['message']}` <br>\n",
159158
];
160159
}

src/Migrations/Migration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static public function run(?string $type = null, ?string $column = null)
121121
// Check if method exist
122122
if(!in_array(strtolower($type), ['up', 'drop', 'column']) || !method_exists(__CLASS__, strtolower($type))){
123123
return [
124-
'response' => self::ERROR_404,
124+
'status' => self::ERROR_404,
125125
'message' => sprintf("The method or type `%s` you're trying to call doesn't exist", $type)
126126
];
127127
}
@@ -140,9 +140,9 @@ static public function run(?string $type = null, ?string $column = null)
140140

141141
// store all messages
142142
$errorMessage[] = $handle['message'];
143-
143+
144144
// error occured stop code execution
145-
if($handle['response'] != self::ERROR_200){
145+
if($handle['status'] != self::ERROR_200){
146146
$errorstatus = self::ERROR_404;
147147
break;
148148
}
@@ -152,7 +152,7 @@ static public function run(?string $type = null, ?string $column = null)
152152
unset($_SESSION[self::getSession()]);
153153

154154
return [
155-
'response' => $errorstatus,
155+
'status' => $errorstatus,
156156
'message' => implode("\n", $errorMessage)
157157
];
158158
}

src/Migrations/Schema.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static public function dropTable(?string $tableName)
8282
self::initSchemaDatabase();
8383

8484
// handle error
85-
$handle = self::checkDBConnect($tableName);
85+
$handle = self::checkDBConnect();
8686
if(is_array($handle)){
8787
return $handle;
8888
}
@@ -122,7 +122,7 @@ static public function dropColumn(?string $tableName, ?string $columnName)
122122
self::initSchemaDatabase();
123123

124124
// handle error
125-
$handle = self::checkDBConnect($tableName);
125+
$handle = self::checkDBConnect();
126126
if(is_array($handle)){
127127
return $handle;
128128
}
@@ -166,11 +166,10 @@ static public function dropColumn(?string $tableName, ?string $columnName)
166166

167167
/**
168168
* Check database connection error
169-
* @param string $tableName
170169
*
171170
* @return mixed
172171
*/
173-
static private function checkDBConnect(?string $tableName = null)
172+
static private function checkDBConnect()
174173
{
175174
$style = self::getStyle();
176175

@@ -182,7 +181,7 @@ static private function checkDBConnect(?string $tableName = null)
182181
'message' => "Connection Error
183182
<span style='background: #ee0707; {$style}'>
184183
Database Connection Error
185-
</span> on `{$tableName}`
184+
</span>
186185
`{$dbConnection['message']}` <br>\n",
187186
];
188187
}

src/Query/MySqlExec.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ protected function errorTemp(Throwable|PDOException $e, $prepareQueryError = fal
227227
}
228228

229229
return [
230-
'response' => self::ERROR_404,
231-
'message' => preg_replace(
230+
'status' => self::ERROR_404,
231+
'message' => preg_replace(
232232
'/^[ \t]+|[ \t]+$/m', '',
233233
" $dbError
234234
{$exception->getTraceAsString()}
@@ -261,14 +261,14 @@ protected function analizeTable()
261261
// if an error
262262
if($result['error']){
263263
return [
264-
'response' => self::ERROR_404,
264+
'status' => self::ERROR_404,
265265
'message' => $this->console::replaceLeadEndSpace($result['message']),
266266
'time' => $this->timer,
267267
];
268268
}
269269

270270
return [
271-
'response' => self::ERROR_200,
271+
'status' => self::ERROR_200,
272272
'message' => $this->console::replaceLeadEndSpace($result['message']),
273273
'time' => $this->timer,
274274
];
@@ -299,14 +299,14 @@ protected function repairTable()
299299
// if an error
300300
if($result['error']){
301301
return [
302-
'response' => self::ERROR_404,
302+
'status' => self::ERROR_404,
303303
'message' => $this->console::replaceLeadEndSpace($result['message']),
304304
'time' => $this->timer,
305305
];
306306
}
307307

308308
return [
309-
'response' => self::ERROR_200,
309+
'status' => self::ERROR_200,
310310
'message' => $this->console::replaceLeadEndSpace($result['message']),
311311
'time' => $this->timer,
312312
];

src/Schema/Insertion.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ public function optimize(string|array $table = [])
6969

7070
// analize
7171
$analize = $this->analizeTable();
72-
if($analize['response'] !== self::ERROR_200){
72+
if($analize['status'] !== self::ERROR_200){
7373
return $analize;
7474
}
7575

7676
// repair
7777
$repair = $this->repairTable();
78-
if($repair['response'] !== self::ERROR_200){
78+
if($repair['status'] !== self::ERROR_200){
7979
return $repair;
8080
}
8181

8282
return (object) [
83-
'response' => self::ERROR_200,
83+
'status' => self::ERROR_200,
8484
'analize' => $analize,
8585
'repair' => $repair,
8686
];

src/Schema/OrmDotEnv.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ static public function load(?string $path = null)
8282
$dotenv->load();
8383

8484
return [
85-
'response' => self::ERROR_200,
86-
'message' => ".env File Loaded Successfully",
85+
'status' => self::ERROR_200,
86+
'message' => ".env File Loaded Successfully",
8787
'path' => self::$immutable,
8888
];
8989
}catch(Exception $e){
9090
return [
91-
'response' => self::ERROR_404,
92-
'message' => $e->getMessage(),
91+
'status' => self::ERROR_404,
92+
'message' => $e->getMessage(),
9393
'path' => self::$immutable,
9494
];
9595
}
@@ -105,7 +105,7 @@ static public function load(?string $path = null)
105105
static public function loadOrFail(?string $path = null)
106106
{
107107
$getStatus = self::load($path);
108-
if($getStatus['response'] != self::ERROR_200){
108+
if($getStatus['status'] != self::ERROR_200){
109109
self::$object->dump(
110110
"{$getStatus['message']} \n" .
111111
(new Exception)->getTraceAsString()

0 commit comments

Comments
 (0)