@@ -107,11 +107,12 @@ |
||
107 | 107 | { |
108 | 108 | $this->$prop = $value; |
109 | 109 | |
110 | - if (!in_array($prop, $this->changedFields)) |
|
111 | - $this->changedFields[] = $prop; |
|
110 | + if (!in_array($prop, $this->changedFields)) { |
|
111 | + $this->changedFields[] = $prop; |
|
112 | + } |
|
113 | + } else { |
|
114 | + throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
112 | 115 | } |
113 | - else |
|
114 | - throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
115 | 116 | } |
116 | 117 | } |
117 | 118 |
@@ -31,15 +31,17 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($options) |
33 | 33 | { |
34 | - if (!array_key_exists("dbchar", $options)) |
|
35 | - $options["dbchar"] = "AL32UTF8"; |
|
34 | + if (!array_key_exists("dbchar", $options)) { |
|
35 | + $options["dbchar"] = "AL32UTF8"; |
|
36 | + } |
|
36 | 37 | |
37 | 38 | parent::__construct($options); |
38 | 39 | |
39 | 40 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
40 | 41 | |
41 | - if ($auto_connect) |
|
42 | - $this->connect(); |
|
42 | + if ($auto_connect) { |
|
43 | + $this->connect(); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | /** |
@@ -52,8 +54,9 @@ discard block |
||
52 | 54 | */ |
53 | 55 | public function connect() |
54 | 56 | { |
55 | - if (!extension_loaded('oci8')) |
|
56 | - throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
57 | + if (!extension_loaded('oci8')) { |
|
58 | + throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
59 | + } |
|
57 | 60 | |
58 | 61 | $connection_string = (is_null($this->dbhost) || empty($this->dbhost)) |
59 | 62 | ? $this->dbname |
@@ -106,14 +109,15 @@ discard block |
||
106 | 109 | ]; |
107 | 110 | |
108 | 111 | $this->error($error["message"]); |
112 | + } else { |
|
113 | + $this->error($error["code"], $error["message"]); |
|
109 | 114 | } |
110 | - else |
|
111 | - $this->error($error["code"], $error["message"]); |
|
112 | 115 | |
113 | - if (array_key_exists("code", $error)) |
|
114 | - throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
115 | - else |
|
116 | - throw new Exception\InvalidQueryException($error["message"]); |
|
116 | + if (array_key_exists("code", $error)) { |
|
117 | + throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
118 | + } else { |
|
119 | + throw new Exception\InvalidQueryException($error["message"]); |
|
120 | + } |
|
117 | 121 | } |
118 | 122 | |
119 | 123 | # Bound variables |
@@ -151,8 +155,9 @@ discard block |
||
151 | 155 | $this->numRows = count($rows); |
152 | 156 | $this->numFields = oci_num_fields($stid); |
153 | 157 | |
154 | - if ($this->transac_mode) |
|
155 | - $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
158 | + if ($this->transac_mode) { |
|
159 | + $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
160 | + } |
|
156 | 161 | |
157 | 162 | $this->result = $stid; |
158 | 163 | |
@@ -201,9 +206,8 @@ discard block |
||
201 | 206 | { |
202 | 207 | $data[] = $row; |
203 | 208 | } |
204 | - } |
|
205 | - else |
|
206 | - /* |
|
209 | + } else { |
|
210 | + /* |
|
207 | 211 | * "This kind of exception should lead directly to a fix in your code" |
208 | 212 | * So much production tests tell us this error is throwed because developers |
209 | 213 | * execute toArray() before execute(). |
@@ -211,6 +215,7 @@ discard block |
||
211 | 215 | * Ref: http://php.net/manual/en/class.logicexception.php |
212 | 216 | */ |
213 | 217 | throw new \LogicException('There are not data in the buffer!'); |
218 | + } |
|
214 | 219 | |
215 | 220 | $this->arrayResult = $data; |
216 | 221 | |
@@ -224,7 +229,8 @@ discard block |
||
224 | 229 | */ |
225 | 230 | public function __destruct() |
226 | 231 | { |
227 | - if ($this->dbconn) |
|
228 | - oci_close($this->dbconn); |
|
232 | + if ($this->dbconn) { |
|
233 | + oci_close($this->dbconn); |
|
234 | + } |
|
229 | 235 | } |
230 | 236 | } |
231 | 237 | \ No newline at end of file |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | { |
74 | 74 | $k++; |
75 | 75 | |
76 | - if (is_null($value)) |
|
77 | - $parsed_where[] = "$key IS NULL"; |
|
78 | - elseif ($value instanceof SQLFunction) |
|
79 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
80 | - elseif (is_array($value)) |
|
76 | + if (is_null($value)) { |
|
77 | + $parsed_where[] = "$key IS NULL"; |
|
78 | + } elseif ($value instanceof SQLFunction) { |
|
79 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
80 | + } elseif (is_array($value)) |
|
81 | 81 | { |
82 | 82 | $parsed_in = []; |
83 | 83 | |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
103 | - } |
|
104 | - else |
|
103 | + } else |
|
105 | 104 | { |
106 | 105 | switch ($driver) |
107 | 106 | { |
@@ -119,18 +118,19 @@ discard block |
||
119 | 118 | } |
120 | 119 | |
121 | 120 | $where = "WHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where); |
121 | + } else { |
|
122 | + $where = ""; |
|
122 | 123 | } |
123 | - else |
|
124 | - $where = ""; |
|
125 | 124 | |
126 | 125 | $table = $this->entity->getTableName(); |
127 | 126 | |
128 | 127 | $sql = "SELECT * \r\nFROM {$table}\r\n$where"; |
129 | 128 | |
130 | - if (count($bind_values)) |
|
131 | - $this->getDriver()->getDb()->execute($sql, $bind_values); |
|
132 | - else |
|
133 | - $this->getDriver()->getDb()->execute($sql); |
|
129 | + if (count($bind_values)) { |
|
130 | + $this->getDriver()->getDb()->execute($sql, $bind_values); |
|
131 | + } else { |
|
132 | + $this->getDriver()->getDb()->execute($sql); |
|
133 | + } |
|
134 | 134 | |
135 | 135 | return $this->getDriver()->getDb()->getArrayResult(); |
136 | 136 | } |
@@ -147,8 +147,9 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function insert(Array $data) |
149 | 149 | { |
150 | - if (!count($data)) |
|
151 | - throw new \LogicException("Missing values for INSERT statement!"); |
|
150 | + if (!count($data)) { |
|
151 | + throw new \LogicException("Missing values for INSERT statement!"); |
|
152 | + } |
|
152 | 153 | |
153 | 154 | $bind_values = []; |
154 | 155 | |
@@ -171,11 +172,11 @@ discard block |
||
171 | 172 | continue; |
172 | 173 | } |
173 | 174 | |
174 | - if (is_null($value)) |
|
175 | - $value = "NULL"; |
|
176 | - elseif ($value instanceof SQLFunction) |
|
177 | - $value = $value->getStatement(); |
|
178 | - else { |
|
175 | + if (is_null($value)) { |
|
176 | + $value = "NULL"; |
|
177 | + } elseif ($value instanceof SQLFunction) { |
|
178 | + $value = $value->getStatement(); |
|
179 | + } else { |
|
179 | 180 | |
180 | 181 | switch ($driver) |
181 | 182 | { |
@@ -225,11 +226,13 @@ discard block |
||
225 | 226 | { |
226 | 227 | $parsed_set = []; |
227 | 228 | |
228 | - if (!count($set)) |
|
229 | - throw new \LogicException("You cannot update rows without SET clause"); |
|
229 | + if (!count($set)) { |
|
230 | + throw new \LogicException("You cannot update rows without SET clause"); |
|
231 | + } |
|
230 | 232 | |
231 | - if (!count($where)) |
|
232 | - throw new SecurityException("You cannot update rows without WHERE clause!"); |
|
233 | + if (!count($where)) { |
|
234 | + throw new SecurityException("You cannot update rows without WHERE clause!"); |
|
235 | + } |
|
233 | 236 | |
234 | 237 | $bind_values = []; |
235 | 238 | |
@@ -241,11 +244,11 @@ discard block |
||
241 | 244 | { |
242 | 245 | $k++; |
243 | 246 | |
244 | - if (is_null($value)) |
|
245 | - $parsed_set[] = "$key = NULL"; |
|
246 | - elseif ($value instanceof SQLFunction) |
|
247 | - $parsed_set[] = "$key = " . $value->getStatement(); |
|
248 | - elseif (is_array($value)) |
|
247 | + if (is_null($value)) { |
|
248 | + $parsed_set[] = "$key = NULL"; |
|
249 | + } elseif ($value instanceof SQLFunction) { |
|
250 | + $parsed_set[] = "$key = " . $value->getStatement(); |
|
251 | + } elseif (is_array($value)) |
|
249 | 252 | { |
250 | 253 | $parsed_in = []; |
251 | 254 | |
@@ -256,8 +259,9 @@ discard block |
||
256 | 259 | case 'Oci8': |
257 | 260 | |
258 | 261 | # [POSSIBLE BUG] - To Future revision (What about non-string values ?) |
259 | - if (is_string($in_value)) |
|
260 | - $parsed_in[] = ":$k"; |
|
262 | + if (is_string($in_value)) { |
|
263 | + $parsed_in[] = ":$k"; |
|
264 | + } |
|
261 | 265 | |
262 | 266 | $bind_values[":$k"] = $in_value; |
263 | 267 | break; |
@@ -272,8 +276,7 @@ discard block |
||
272 | 276 | } |
273 | 277 | |
274 | 278 | $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
275 | - } |
|
276 | - else |
|
279 | + } else |
|
277 | 280 | { |
278 | 281 | switch ($driver) |
279 | 282 | { |
@@ -298,11 +301,11 @@ discard block |
||
298 | 301 | { |
299 | 302 | $k++; |
300 | 303 | |
301 | - if (is_null($value)) |
|
302 | - $parsed_where[] = "$key IS NULL"; |
|
303 | - elseif ($value instanceof SQLFunction) |
|
304 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
305 | - elseif (is_array($value)) |
|
304 | + if (is_null($value)) { |
|
305 | + $parsed_where[] = "$key IS NULL"; |
|
306 | + } elseif ($value instanceof SQLFunction) { |
|
307 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
308 | + } elseif (is_array($value)) |
|
306 | 309 | { |
307 | 310 | $parsed_in = []; |
308 | 311 | |
@@ -325,8 +328,7 @@ discard block |
||
325 | 328 | } |
326 | 329 | |
327 | 330 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
328 | - } |
|
329 | - else |
|
331 | + } else |
|
330 | 332 | { |
331 | 333 | switch ($driver) |
332 | 334 | { |
@@ -378,11 +380,11 @@ discard block |
||
378 | 380 | { |
379 | 381 | $k++; |
380 | 382 | |
381 | - if (is_null($value)) |
|
382 | - $parsed_where[] = "$key IS NULL"; |
|
383 | - elseif ($value instanceof SQLFunction) |
|
384 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
385 | - elseif (is_array($value)) |
|
383 | + if (is_null($value)) { |
|
384 | + $parsed_where[] = "$key IS NULL"; |
|
385 | + } elseif ($value instanceof SQLFunction) { |
|
386 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
387 | + } elseif (is_array($value)) |
|
386 | 388 | { |
387 | 389 | $parsed_in = []; |
388 | 390 | |
@@ -405,8 +407,7 @@ discard block |
||
405 | 407 | } |
406 | 408 | |
407 | 409 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
408 | - } |
|
409 | - else |
|
410 | + } else |
|
410 | 411 | { |
411 | 412 | switch ($driver) |
412 | 413 | { |
@@ -424,9 +425,9 @@ discard block |
||
424 | 425 | } |
425 | 426 | |
426 | 427 | $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where); |
428 | + } else { |
|
429 | + throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead."); |
|
427 | 430 | } |
428 | - else |
|
429 | - throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead."); |
|
430 | 431 | |
431 | 432 | $table = $this->entity->getTableName(); |
432 | 433 |
@@ -31,15 +31,17 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($options) |
33 | 33 | { |
34 | - if (!array_key_exists("dbchar", $options)) |
|
35 | - $options["dbchar"] = "UTF-8"; |
|
34 | + if (!array_key_exists("dbchar", $options)) { |
|
35 | + $options["dbchar"] = "UTF-8"; |
|
36 | + } |
|
36 | 37 | |
37 | 38 | parent::__construct($options); |
38 | 39 | |
39 | 40 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
40 | 41 | |
41 | - if ($auto_connect) |
|
42 | - $this->connect(); |
|
42 | + if ($auto_connect) { |
|
43 | + $this->connect(); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | /** |
@@ -52,11 +54,13 @@ discard block |
||
52 | 54 | */ |
53 | 55 | public function connect() |
54 | 56 | { |
55 | - if (!extension_loaded('sqlsrv')) |
|
56 | - throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
57 | + if (!extension_loaded('sqlsrv')) { |
|
58 | + throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
59 | + } |
|
57 | 60 | |
58 | - if (!is_null($this->dbport) && !empty($this->dbport)) |
|
59 | - $this->dbhost .= ', ' . $this->dbport; |
|
61 | + if (!is_null($this->dbport) && !empty($this->dbport)) { |
|
62 | + $this->dbhost .= ', ' . $this->dbport; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar); |
62 | 66 | $conn = sqlsrv_connect($this->dbhost, $db_info); |
@@ -137,13 +141,13 @@ discard block |
||
137 | 141 | } |
138 | 142 | |
139 | 143 | $exec = sqlsrv_execute($stmt); |
140 | - } |
|
141 | - else |
|
144 | + } else |
|
142 | 145 | { |
143 | - if ($isSelectStm) |
|
144 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
145 | - else |
|
146 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
146 | + if ($isSelectStm) { |
|
147 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
148 | + } else { |
|
149 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
150 | + } |
|
147 | 151 | } |
148 | 152 | |
149 | 153 | if ($exec === false) |
@@ -163,11 +167,13 @@ discard block |
||
163 | 167 | $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows; |
164 | 168 | $this->numFields = sqlsrv_num_fields($this->result); |
165 | 169 | |
166 | - if ($isInsertStm || $isUpdateStm || $isDeleteStm) |
|
167 | - $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
170 | + if ($isInsertStm || $isUpdateStm || $isDeleteStm) { |
|
171 | + $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
172 | + } |
|
168 | 173 | |
169 | - if ($this->transac_mode) |
|
170 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
174 | + if ($this->transac_mode) { |
|
175 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
176 | + } |
|
171 | 177 | |
172 | 178 | return $this->result; |
173 | 179 | } |
@@ -234,9 +240,8 @@ discard block |
||
234 | 240 | { |
235 | 241 | $data[] = $row; |
236 | 242 | } |
237 | - } |
|
238 | - else |
|
239 | - /* |
|
243 | + } else { |
|
244 | + /* |
|
240 | 245 | * "This kind of exception should lead directly to a fix in your code" |
241 | 246 | * So much production tests tell us this error is throwed because developers |
242 | 247 | * execute toArray() before execute(). |
@@ -244,6 +249,7 @@ discard block |
||
244 | 249 | * Ref: http://php.net/manual/en/class.logicexception.php |
245 | 250 | */ |
246 | 251 | throw new \LogicException('There are not data in the buffer!'); |
252 | + } |
|
247 | 253 | |
248 | 254 | $this->arrayResult = $data; |
249 | 255 | |
@@ -257,7 +263,8 @@ discard block |
||
257 | 263 | */ |
258 | 264 | public function __destruct() |
259 | 265 | { |
260 | - if ($this->dbconn) |
|
261 | - sqlsrv_close($this->dbconn); |
|
266 | + if ($this->dbconn) { |
|
267 | + sqlsrv_close($this->dbconn); |
|
268 | + } |
|
262 | 269 | } |
263 | 270 | } |
264 | 271 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | public function prepare() |
59 | 59 | { |
60 | 60 | # start sessions |
61 | - if (!isset($_SESSION)) |
|
62 | - session_start(); |
|
61 | + if (!isset($_SESSION)) { |
|
62 | + session_start(); |
|
63 | + } |
|
63 | 64 | } |
64 | 65 | |
65 | 66 | /** |
@@ -91,8 +92,7 @@ discard block |
||
91 | 92 | |
92 | 93 | // Best way to view all possible errors |
93 | 94 | error_reporting(-1); |
94 | - } |
|
95 | - else { |
|
95 | + } else { |
|
96 | 96 | ini_set('display_errors', 0); |
97 | 97 | error_reporting(-1); |
98 | 98 | } |
@@ -109,10 +109,11 @@ discard block |
||
109 | 109 | |
110 | 110 | foreach ($app_config_file["router"]["routes"] as $name => $route) |
111 | 111 | { |
112 | - if ($route instanceof \Zend\Router\Http\RouteInterface) |
|
113 | - $this->getRouter()->addZendRoute($name, $route); |
|
114 | - else |
|
115 | - $this->getRouter()->addRoute($route); |
|
112 | + if ($route instanceof \Zend\Router\Http\RouteInterface) { |
|
113 | + $this->getRouter()->addZendRoute($name, $route); |
|
114 | + } else { |
|
115 | + $this->getRouter()->addRoute($route); |
|
116 | + } |
|
116 | 117 | } |
117 | 118 | } |
118 | 119 | |
@@ -146,14 +147,15 @@ discard block |
||
146 | 147 | * This instruction include each module declared in application.config.php |
147 | 148 | * Each module has an autoloader to load its classes (controllers and models) |
148 | 149 | */ |
149 | - if (file_exists("module/".$module."/Module.php")) |
|
150 | - include("module/".$module."/Module.php"); |
|
150 | + if (file_exists("module/".$module."/Module.php")) { |
|
151 | + include("module/".$module."/Module.php"); |
|
152 | + } |
|
151 | 153 | |
152 | 154 | spl_autoload_register($module . "\Module::loader"); |
153 | 155 | } |
156 | + } else { |
|
157 | + throw new \RuntimeException("The application must have at least one module"); |
|
154 | 158 | } |
155 | - else |
|
156 | - throw new \RuntimeException("The application must have at least one module"); |
|
157 | 159 | } |
158 | 160 | |
159 | 161 | /** |
@@ -175,8 +177,9 @@ discard block |
||
175 | 177 | $uri .= !empty($controller) ? '/' . $controller : ""; |
176 | 178 | $uri .= !empty($view) ? '/' . $view : ""; |
177 | 179 | |
178 | - if (empty($uri)) |
|
179 | - $uri = "/"; |
|
180 | + if (empty($uri)) { |
|
181 | + $uri = "/"; |
|
182 | + } |
|
180 | 183 | |
181 | 184 | $request->setUri($uri); |
182 | 185 | |
@@ -191,9 +194,9 @@ discard block |
||
191 | 194 | $view = $params["action"]; |
192 | 195 | |
193 | 196 | $this->router->setIdentifiers($module, $controller, $view); |
197 | + } else { |
|
198 | + $this->router->setIdentifiers($module, $controller, $view); |
|
194 | 199 | } |
195 | - else |
|
196 | - $this->router->setIdentifiers($module, $controller, $view); |
|
197 | 200 | |
198 | 201 | $this->router->run(); |
199 | 202 | } |
@@ -216,8 +216,9 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function getArrayResult() |
218 | 218 | { |
219 | - if (!empty($this->arrayResult)) |
|
220 | - return $this->arrayResult; |
|
219 | + if (!empty($this->arrayResult)) { |
|
220 | + return $this->arrayResult; |
|
221 | + } |
|
221 | 222 | |
222 | 223 | return $this->toArray(); |
223 | 224 | } |
@@ -313,8 +314,9 @@ discard block |
||
313 | 314 | */ |
314 | 315 | public function autocommit($value) |
315 | 316 | { |
316 | - if ($this->transac_mode) |
|
317 | - throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
317 | + if ($this->transac_mode) { |
|
318 | + throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
319 | + } |
|
318 | 320 | |
319 | 321 | $this->autocommit = $value; |
320 | 322 | } |
@@ -330,8 +332,9 @@ discard block |
||
330 | 332 | { |
331 | 333 | foreach ($options as $option => $value) |
332 | 334 | { |
333 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
334 | - $this->{'set'.$option}($value); |
|
335 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
336 | + $this->{'set'.$option}($value); |
|
337 | + } |
|
335 | 338 | } |
336 | 339 | } |
337 | 340 | |
@@ -375,8 +378,9 @@ discard block |
||
375 | 378 | */ |
376 | 379 | public function reconnect() |
377 | 380 | { |
378 | - if (!$this->isConnected()) |
|
379 | - throw new \LogicException("Connection was not established"); |
|
381 | + if (!$this->isConnected()) { |
|
382 | + throw new \LogicException("Connection was not established"); |
|
383 | + } |
|
380 | 384 | |
381 | 385 | $this->disconnect(); |
382 | 386 | return $this->connect(); |
@@ -405,8 +409,9 @@ discard block |
||
405 | 409 | */ |
406 | 410 | public function disconnect() |
407 | 411 | { |
408 | - if (!$this->isConnected()) |
|
409 | - throw new \LogicException("Connection was not established"); |
|
412 | + if (!$this->isConnected()) { |
|
413 | + throw new \LogicException("Connection was not established"); |
|
414 | + } |
|
410 | 415 | } |
411 | 416 | |
412 | 417 | /** |
@@ -418,11 +423,13 @@ discard block |
||
418 | 423 | */ |
419 | 424 | public function beginTransaction() |
420 | 425 | { |
421 | - if (!$this->isConnected()) |
|
422 | - $this->connect(); |
|
426 | + if (!$this->isConnected()) { |
|
427 | + $this->connect(); |
|
428 | + } |
|
423 | 429 | |
424 | - if ($this->transac_mode) |
|
425 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
430 | + if ($this->transac_mode) { |
|
431 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
432 | + } |
|
426 | 433 | |
427 | 434 | $this->transac_mode = true; |
428 | 435 | } |
@@ -436,16 +443,19 @@ discard block |
||
436 | 443 | */ |
437 | 444 | public function endTransaction() |
438 | 445 | { |
439 | - if (!$this->transac_mode) |
|
440 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
446 | + if (!$this->transac_mode) { |
|
447 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
448 | + } |
|
441 | 449 | |
442 | - if (is_null($this->transac_result)) |
|
443 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
450 | + if (is_null($this->transac_result)) { |
|
451 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
452 | + } |
|
444 | 453 | |
445 | - if ($this->transac_result) |
|
446 | - $this->commit(); |
|
447 | - else |
|
448 | - $this->rollback(); |
|
454 | + if ($this->transac_result) { |
|
455 | + $this->commit(); |
|
456 | + } else { |
|
457 | + $this->rollback(); |
|
458 | + } |
|
449 | 459 | |
450 | 460 | $this->result = $this->transac_result; |
451 | 461 |
@@ -83,12 +83,10 @@ discard block |
||
83 | 83 | |
84 | 84 | try { |
85 | 85 | $conn->disconnect(); |
86 | - } |
|
87 | - catch (\Exception $e) |
|
86 | + } catch (\Exception $e) |
|
88 | 87 | { |
89 | 88 | $errorObject = ($e instanceof \LogicException); |
90 | - } |
|
91 | - finally |
|
89 | + } finally |
|
92 | 90 | { |
93 | 91 | $this->assertNotTrue($conn->isConnected()); |
94 | 92 | $this->assertTrue($errorObject, $e->getMessage()); |
@@ -124,12 +122,10 @@ discard block |
||
124 | 122 | |
125 | 123 | try { |
126 | 124 | $conn->reconnect(); |
127 | - } |
|
128 | - catch (\Exception $e) |
|
125 | + } catch (\Exception $e) |
|
129 | 126 | { |
130 | 127 | $errorObject = ($e instanceof \LogicException); |
131 | - } |
|
132 | - finally |
|
128 | + } finally |
|
133 | 129 | { |
134 | 130 | $this->assertTrue($errorObject, $e->getMessage()); |
135 | 131 | $this->assertNotTrue($conn->isConnected()); |
@@ -154,13 +150,11 @@ discard block |
||
154 | 150 | |
155 | 151 | try { |
156 | 152 | $mysqliObject = $conn->connect(); |
157 | - } |
|
158 | - catch (\Exception $e) |
|
153 | + } catch (\Exception $e) |
|
159 | 154 | { |
160 | 155 | $errorObject = ($e instanceof ConnectionException); |
161 | 156 | $message = $e->getMessage(); |
162 | - } |
|
163 | - finally |
|
157 | + } finally |
|
164 | 158 | { |
165 | 159 | $this->assertTrue($errorObject, $message); |
166 | 160 | $this->assertNotTrue($conn->isConnected()); |
@@ -31,15 +31,17 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($options) |
33 | 33 | { |
34 | - if (!array_key_exists("dbchar", $options)) |
|
35 | - $options["dbchar"] = "utf8"; |
|
34 | + if (!array_key_exists("dbchar", $options)) { |
|
35 | + $options["dbchar"] = "utf8"; |
|
36 | + } |
|
36 | 37 | |
37 | 38 | parent::__construct($options); |
38 | 39 | |
39 | 40 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
40 | 41 | |
41 | - if ($auto_connect) |
|
42 | - $this->connect(); |
|
42 | + if ($auto_connect) { |
|
43 | + $this->connect(); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | /** |
@@ -52,13 +54,15 @@ discard block |
||
52 | 54 | */ |
53 | 55 | public function connect() |
54 | 56 | { |
55 | - if (!extension_loaded('mysqli')) |
|
56 | - throw new \RuntimeException("The Mysqli extension is not loaded"); |
|
57 | + if (!extension_loaded('mysqli')) { |
|
58 | + throw new \RuntimeException("The Mysqli extension is not loaded"); |
|
59 | + } |
|
57 | 60 | |
58 | - if (!is_null($this->dbport) && !empty($this->dbport)) |
|
59 | - $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport); |
|
60 | - else |
|
61 | - $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); |
|
61 | + if (!is_null($this->dbport) && !empty($this->dbport)) { |
|
62 | + $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport); |
|
63 | + } else { |
|
64 | + $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); |
|
65 | + } |
|
62 | 66 | |
63 | 67 | if ($conn->connect_errno) |
64 | 68 | { |
@@ -68,8 +72,7 @@ discard block |
||
68 | 72 | * the warning message "Property access is not allowed yet". |
69 | 73 | */ |
70 | 74 | throw new Exception\ConnectionException(mysqli_connect_error(), mysqli_connect_errno()); |
71 | - } |
|
72 | - else |
|
75 | + } else |
|
73 | 76 | { |
74 | 77 | $this->dbconn = $conn; |
75 | 78 | $this->dbconn->set_charset($this->dbchar); |
@@ -116,13 +119,15 @@ discard block |
||
116 | 119 | |
117 | 120 | for ($i = 0; $i < $n_params; $i++) |
118 | 121 | { |
119 | - if (is_string($param_values[$i])) |
|
120 | - $bind_types .= 's'; |
|
121 | - else if(is_float($param_values[$i])) |
|
122 | - $bind_types .= 'd'; |
|
122 | + if (is_string($param_values[$i])) { |
|
123 | + $bind_types .= 's'; |
|
124 | + } else if(is_float($param_values[$i])) { |
|
125 | + $bind_types .= 'd'; |
|
126 | + } |
|
123 | 127 | # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?) |
124 | - else |
|
125 | - $bind_types .= 's'; |
|
128 | + else { |
|
129 | + $bind_types .= 's'; |
|
130 | + } |
|
126 | 131 | |
127 | 132 | $bind_values[] = '$param_values[' . $i . ']'; |
128 | 133 | } |
@@ -143,12 +148,12 @@ discard block |
||
143 | 148 | * It is useful to prevent rollback transactions on insert statements because |
144 | 149 | * insert statement do not free results. |
145 | 150 | */ |
146 | - if ($res) |
|
147 | - $this->result = $res; |
|
151 | + if ($res) { |
|
152 | + $this->result = $res; |
|
153 | + } |
|
148 | 154 | } |
149 | 155 | } |
150 | - } |
|
151 | - else |
|
156 | + } else |
|
152 | 157 | { |
153 | 158 | $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL); |
154 | 159 | |
@@ -165,20 +170,23 @@ discard block |
||
165 | 170 | } |
166 | 171 | |
167 | 172 | # identify SELECT, SHOW, DESCRIBE or EXPLAIN queries |
168 | - if (is_object($this->result) && property_exists($this->result, 'num_rows')) |
|
169 | - $this->numRows = $this->result->num_rows; |
|
170 | - else |
|
173 | + if (is_object($this->result) && property_exists($this->result, 'num_rows')) { |
|
174 | + $this->numRows = $this->result->num_rows; |
|
175 | + } else |
|
171 | 176 | { |
172 | 177 | # affected_rows return the same of num_rows on select statements! |
173 | - if (property_exists($this->dbconn, 'affected_rows')) |
|
174 | - $this->rowsAffected = $this->dbconn->affected_rows; |
|
178 | + if (property_exists($this->dbconn, 'affected_rows')) { |
|
179 | + $this->rowsAffected = $this->dbconn->affected_rows; |
|
180 | + } |
|
175 | 181 | } |
176 | 182 | |
177 | - if (property_exists($this->dbconn, 'field_count')) |
|
178 | - $this->numFields = $this->dbconn->field_count; |
|
183 | + if (property_exists($this->dbconn, 'field_count')) { |
|
184 | + $this->numFields = $this->dbconn->field_count; |
|
185 | + } |
|
179 | 186 | |
180 | - if ($this->transac_mode) |
|
181 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
187 | + if ($this->transac_mode) { |
|
188 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
189 | + } |
|
182 | 190 | |
183 | 191 | /* |
184 | 192 | * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, * and TRUE for other successful queries, it should be handled to return only objects or resources. |
@@ -255,9 +263,8 @@ discard block |
||
255 | 263 | { |
256 | 264 | $data[] = $row; |
257 | 265 | } |
258 | - } |
|
259 | - else |
|
260 | - /* |
|
266 | + } else { |
|
267 | + /* |
|
261 | 268 | * "This kind of exception should lead directly to a fix in your code" |
262 | 269 | * So much production tests tell us this error is throwed because developers |
263 | 270 | * execute toArray() before execute(). |
@@ -265,6 +272,7 @@ discard block |
||
265 | 272 | * Ref: http://php.net/manual/en/class.logicexception.php |
266 | 273 | */ |
267 | 274 | throw new \LogicException('There are not data in the buffer!'); |
275 | + } |
|
268 | 276 | |
269 | 277 | $this->arrayResult = $data; |
270 | 278 | |
@@ -279,7 +287,8 @@ discard block |
||
279 | 287 | public function __destruct() |
280 | 288 | { |
281 | 289 | # prevent "Property access is not allowed yet" with @ on failure connections |
282 | - if ($this->dbconn !== false && !is_null($this->dbconn)) |
|
283 | - @$this->dbconn->close(); |
|
290 | + if ($this->dbconn !== false && !is_null($this->dbconn)) { |
|
291 | + @$this->dbconn->close(); |
|
292 | + } |
|
284 | 293 | } |
285 | 294 | } |
286 | 295 | \ No newline at end of file |
@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | { |
85 | 85 | foreach ($this->ls($directory) as $item) |
86 | 86 | { |
87 | - if ($item != '.' && $item != '..') |
|
88 | - $contents[] = $item; |
|
87 | + if ($item != '.' && $item != '..') { |
|
88 | + $contents[] = $item; |
|
89 | + } |
|
89 | 90 | } |
90 | 91 | |
91 | 92 | $allContents = $contents; |
@@ -100,8 +101,7 @@ discard block |
||
100 | 101 | |
101 | 102 | $this->buffer = $directory.'/'.$i; |
102 | 103 | call_user_func($fileCallback, $this); |
103 | - } |
|
104 | - elseif (is_dir($directory.'/'.$i)) |
|
104 | + } elseif (is_dir($directory.'/'.$i)) |
|
105 | 105 | { |
106 | 106 | $allContents[] = $directory.'/'.$i; |
107 | 107 | |
@@ -117,14 +117,15 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | + } else if (is_file($directory)) { |
|
121 | + throw new \InvalidArgumentException("'$directory' is actually a file"); |
|
122 | + } else { |
|
123 | + throw new \InvalidArgumentException("The directory '$directory' does not exists"); |
|
120 | 124 | } |
121 | - else if (is_file($directory)) |
|
122 | - throw new \InvalidArgumentException("'$directory' is actually a file"); |
|
123 | - else |
|
124 | - throw new \InvalidArgumentException("The directory '$directory' does not exists"); |
|
125 | 125 | |
126 | - if (!is_null($callback)) |
|
127 | - call_user_func($callback, $this); |
|
126 | + if (!is_null($callback)) { |
|
127 | + call_user_func($callback, $this); |
|
128 | + } |
|
128 | 129 | |
129 | 130 | return $allContents; |
130 | 131 | } |
@@ -136,10 +137,11 @@ discard block |
||
136 | 137 | */ |
137 | 138 | public function pwd() |
138 | 139 | { |
139 | - if (getcwd()) |
|
140 | - $this->buffer = getcwd(); |
|
141 | - else |
|
142 | - return false; |
|
140 | + if (getcwd()) { |
|
141 | + $this->buffer = getcwd(); |
|
142 | + } else { |
|
143 | + return false; |
|
144 | + } |
|
143 | 145 | |
144 | 146 | return $this->buffer; |
145 | 147 | } |
@@ -158,9 +160,9 @@ discard block |
||
158 | 160 | |
159 | 161 | $path = (is_null($path) || empty($path)) ? '.' : $path; |
160 | 162 | |
161 | - if (is_file($path)) |
|
162 | - $filesToReturn = array($path); |
|
163 | - else if (is_dir($path)) |
|
163 | + if (is_file($path)) { |
|
164 | + $filesToReturn = array($path); |
|
165 | + } else if (is_dir($path)) |
|
164 | 166 | { |
165 | 167 | $pathIns = dir($path); |
166 | 168 | |
@@ -181,34 +183,37 @@ discard block |
||
181 | 183 | } |
182 | 184 | ); |
183 | 185 | |
184 | - foreach ($dirs as $item) |
|
185 | - $filesToReturn[] = $item; |
|
186 | + foreach ($dirs as $item) { |
|
187 | + $filesToReturn[] = $item; |
|
188 | + } |
|
186 | 189 | |
187 | - foreach ($files as $item) |
|
188 | - $filesToReturn[] = $item; |
|
189 | - } |
|
190 | - else |
|
190 | + foreach ($files as $item) { |
|
191 | + $filesToReturn[] = $item; |
|
192 | + } |
|
193 | + } else |
|
191 | 194 | { |
192 | 195 | while (($item = $pathIns->read()) !== false) |
193 | 196 | { |
194 | - if ($item != '.' && $item != '..') |
|
195 | - $filesToReturn[] = $item; |
|
197 | + if ($item != '.' && $item != '..') { |
|
198 | + $filesToReturn[] = $item; |
|
199 | + } |
|
196 | 200 | } |
197 | 201 | |
198 | 202 | $pathIns->close(); |
199 | 203 | } |
200 | - } |
|
201 | - else { |
|
204 | + } else { |
|
202 | 205 | |
203 | 206 | $contents = $this->ls(); |
204 | 207 | |
205 | 208 | foreach ($contents as $item) |
206 | 209 | { |
207 | - if (!empty($path)) |
|
208 | - if (!strlen(stristr($item, $path)) > 0) |
|
210 | + if (!empty($path)) { |
|
211 | + if (!strlen(stristr($item, $path)) > 0) |
|
209 | 212 | continue; |
210 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
211 | - $filesToReturn[] = $item; |
|
213 | + } |
|
214 | + if (strstr($item,'~') === false && $item != '.' && $item != '..') { |
|
215 | + $filesToReturn[] = $item; |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | } |
214 | 219 | |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | |
229 | 234 | if (is_dir($path)) |
230 | 235 | { |
231 | - if (chdir($path)) |
|
232 | - return true; |
|
236 | + if (chdir($path)) { |
|
237 | + return true; |
|
238 | + } |
|
233 | 239 | } |
234 | 240 | |
235 | 241 | return false; |
@@ -271,12 +277,13 @@ discard block |
||
271 | 277 | { |
272 | 278 | $recursive = is_null($recursive) ? false : $recursive; |
273 | 279 | |
274 | - if (is_null($file)) |
|
275 | - throw new \InvalidArgumentException("Missing first parameter"); |
|
280 | + if (is_null($file)) { |
|
281 | + throw new \InvalidArgumentException("Missing first parameter"); |
|
282 | + } |
|
276 | 283 | |
277 | - if (file_exists($file) && !$recursive) |
|
278 | - unlink($file); |
|
279 | - elseif (is_dir($file) && $recursive) |
|
284 | + if (file_exists($file) && !$recursive) { |
|
285 | + unlink($file); |
|
286 | + } elseif (is_dir($file) && $recursive) |
|
280 | 287 | { |
281 | 288 | $that = $this; |
282 | 289 | |
@@ -305,11 +312,13 @@ discard block |
||
305 | 312 | { |
306 | 313 | $recursive = (is_null($recursive)) ? false : $recursive; |
307 | 314 | |
308 | - if (empty($file) || empty($dest)) |
|
309 | - throw new \InvalidArgumentException("Missing parameters"); |
|
315 | + if (empty($file) || empty($dest)) { |
|
316 | + throw new \InvalidArgumentException("Missing parameters"); |
|
317 | + } |
|
310 | 318 | |
311 | - if (is_dir($file) && !$recursive) |
|
312 | - throw new \RuntimeException("Ommiting directory <<$foo>>"); |
|
319 | + if (is_dir($file) && !$recursive) { |
|
320 | + throw new \RuntimeException("Ommiting directory <<$foo>>"); |
|
321 | + } |
|
313 | 322 | |
314 | 323 | if (is_dir($file) && (is_dir($dest) || !file_exists($dest))) |
315 | 324 | { |
@@ -318,11 +327,13 @@ discard block |
||
318 | 327 | "folders" => [] |
319 | 328 | ]; |
320 | 329 | |
321 | - if (is_dir($dest)) |
|
322 | - $files["folders"][] = basename($file); |
|
330 | + if (is_dir($dest)) { |
|
331 | + $files["folders"][] = basename($file); |
|
332 | + } |
|
323 | 333 | |
324 | - if (!file_exists($dest)) |
|
325 | - mkdir($dest); |
|
334 | + if (!file_exists($dest)) { |
|
335 | + mkdir($dest); |
|
336 | + } |
|
326 | 337 | |
327 | 338 | $that = $this; |
328 | 339 | |
@@ -344,8 +355,9 @@ discard block |
||
344 | 355 | { |
345 | 356 | foreach ($files["folders"] as $folder) |
346 | 357 | { |
347 | - if (!file_exists($dest.'/'.$folder)) |
|
348 | - mkdir("$dest/$folder", 0777, true); |
|
358 | + if (!file_exists($dest.'/'.$folder)) { |
|
359 | + mkdir("$dest/$folder", 0777, true); |
|
360 | + } |
|
349 | 361 | } |
350 | 362 | } |
351 | 363 | |
@@ -353,8 +365,9 @@ discard block |
||
353 | 365 | { |
354 | 366 | foreach ($files["files"] as $item) |
355 | 367 | { |
356 | - if (!file_exists("$dest/$files")) |
|
357 | - copy($item, $dest.'/'.$item); |
|
368 | + if (!file_exists("$dest/$files")) { |
|
369 | + copy($item, $dest.'/'.$item); |
|
370 | + } |
|
358 | 371 | } |
359 | 372 | } |
360 | 373 | } |
@@ -363,9 +376,9 @@ discard block |
||
363 | 376 | |
364 | 377 | if (is_dir($dest)) |
365 | 378 | { |
366 | - if (!$recursive) |
|
367 | - copy($file, $dest.'/'.$file); |
|
368 | - else { |
|
379 | + if (!$recursive) { |
|
380 | + copy($file, $dest.'/'.$file); |
|
381 | + } else { |
|
369 | 382 | |
370 | 383 | $files = array(); |
371 | 384 | $files[0] = array(); |
@@ -383,20 +396,22 @@ discard block |
||
383 | 396 | |
384 | 397 | foreach ($files[1] as $item) |
385 | 398 | { |
386 | - if (!file_exists($dest.'/'.$item)) |
|
387 | - mkdir("$dest/$item", 0777, true); |
|
399 | + if (!file_exists($dest.'/'.$item)) { |
|
400 | + mkdir("$dest/$item", 0777, true); |
|
401 | + } |
|
388 | 402 | } |
389 | 403 | |
390 | 404 | foreach ($files[0] as $item) |
391 | 405 | { |
392 | - if (!file_exists("$dest/$files")) |
|
393 | - copy($item, $dest.'/'.$item); |
|
406 | + if (!file_exists("$dest/$files")) { |
|
407 | + copy($item, $dest.'/'.$item); |
|
408 | + } |
|
394 | 409 | } |
395 | 410 | }); |
396 | 411 | } |
412 | + } else { |
|
413 | + copy($file, $dest); |
|
397 | 414 | } |
398 | - else |
|
399 | - copy($file, $dest); |
|
400 | 415 | |
401 | 416 | return true; |
402 | 417 | } |
@@ -411,17 +426,21 @@ discard block |
||
411 | 426 | */ |
412 | 427 | public function mv($oldfile, $newfile) |
413 | 428 | { |
414 | - if (empty($oldfile)) |
|
415 | - throw new \InvalidArgumentException("Missing first parameter"); |
|
429 | + if (empty($oldfile)) { |
|
430 | + throw new \InvalidArgumentException("Missing first parameter"); |
|
431 | + } |
|
416 | 432 | |
417 | - if (is_dir($newfile)) |
|
418 | - $newfile .= '/'.basename($oldfile); |
|
433 | + if (is_dir($newfile)) { |
|
434 | + $newfile .= '/'.basename($oldfile); |
|
435 | + } |
|
419 | 436 | |
420 | - if ($oldfile == $newfile) |
|
421 | - throw new \Exception("'$oldfile' and '$newfile' are the same file"); |
|
437 | + if ($oldfile == $newfile) { |
|
438 | + throw new \Exception("'$oldfile' and '$newfile' are the same file"); |
|
439 | + } |
|
422 | 440 | |
423 | - if(!rename($oldfile, $newfile)) |
|
424 | - return false; |
|
441 | + if(!rename($oldfile, $newfile)) { |
|
442 | + return false; |
|
443 | + } |
|
425 | 444 | |
426 | 445 | return true; |
427 | 446 | } |
@@ -437,21 +456,24 @@ discard block |
||
437 | 456 | */ |
438 | 457 | public function mkdir($dir, $dest = null, $recursive = null) |
439 | 458 | { |
440 | - if (empty($dir)) |
|
441 | - throw new \InvalidArgumentException("Missing first parameter"); |
|
459 | + if (empty($dir)) { |
|
460 | + throw new \InvalidArgumentException("Missing first parameter"); |
|
461 | + } |
|
442 | 462 | |
443 | - if (empty($dest)) |
|
444 | - $dest = '.'; |
|
463 | + if (empty($dest)) { |
|
464 | + $dest = '.'; |
|
465 | + } |
|
445 | 466 | |
446 | 467 | $recursive = (is_null($recursive)) ? false : $recursive; |
447 | 468 | |
448 | - if ($recursive) |
|
449 | - mkdir("$dest/$dir", 0777, true); |
|
450 | - else { |
|
469 | + if ($recursive) { |
|
470 | + mkdir("$dest/$dir", 0777, true); |
|
471 | + } else { |
|
451 | 472 | if (!is_dir($dir)) |
452 | 473 | { |
453 | - if(!mkdir("$dir", 0777)) |
|
454 | - return false; |
|
474 | + if(!mkdir("$dir", 0777)) { |
|
475 | + return false; |
|
476 | + } |
|
455 | 477 | } |
456 | 478 | } |
457 | 479 | return true; |
@@ -466,12 +488,14 @@ discard block |
||
466 | 488 | */ |
467 | 489 | public function rmdir($dir) |
468 | 490 | { |
469 | - if (is_null($dir) || empty($dir)) |
|
470 | - throw new Exception("Missing parameter for rmdir!"); |
|
491 | + if (is_null($dir) || empty($dir)) { |
|
492 | + throw new Exception("Missing parameter for rmdir!"); |
|
493 | + } |
|
471 | 494 | |
472 | - if (rmdir($dir)) |
|
473 | - return true; |
|
474 | - else |
|
475 | - return false; |
|
495 | + if (rmdir($dir)) { |
|
496 | + return true; |
|
497 | + } else { |
|
498 | + return false; |
|
499 | + } |
|
476 | 500 | } |
477 | 501 | } |
478 | 502 | \ No newline at end of file |