Test Failed
Push — 1.0.0-dev ( b5c6bf...f8836a )
by nguereza
04:02
created
core/classes/Database.php 1 patch
Spacing   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -23,158 +23,158 @@  discard block
 block discarded – undo
23 23
    * along with this program; if not, write to the Free Software
24 24
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
   */
26
-  class Database{
26
+  class Database {
27 27
 	
28 28
 	/**
29 29
 	 * The PDO instance
30 30
 	 * @var object
31 31
 	*/
32
-    private $pdo                 = null;
32
+    private $pdo = null;
33 33
     
34 34
 	/**
35 35
 	 * The database name used for the application
36 36
 	 * @var string
37 37
 	*/
38
-	private $databaseName        = null;
38
+	private $databaseName = null;
39 39
     
40 40
 	/**
41 41
 	 * The SQL SELECT statment
42 42
 	 * @var string
43 43
 	*/
44
-	private $select              = '*';
44
+	private $select = '*';
45 45
 	
46 46
 	/**
47 47
 	 * The SQL FROM statment
48 48
 	 * @var string
49 49
 	*/
50
-    private $from                = null;
50
+    private $from = null;
51 51
 	
52 52
 	/**
53 53
 	 * The SQL WHERE statment
54 54
 	 * @var string
55 55
 	*/
56
-    private $where               = null;
56
+    private $where = null;
57 57
 	
58 58
 	/**
59 59
 	 * The SQL LIMIT statment
60 60
 	 * @var string
61 61
 	*/
62
-    private $limit               = null;
62
+    private $limit = null;
63 63
 	
64 64
 	/**
65 65
 	 * The SQL JOIN statment
66 66
 	 * @var string
67 67
 	*/
68
-    private $join                = null;
68
+    private $join = null;
69 69
 	
70 70
 	/**
71 71
 	 * The SQL ORDER BY statment
72 72
 	 * @var string
73 73
 	*/
74
-    private $orderBy             = null;
74
+    private $orderBy = null;
75 75
 	
76 76
 	/**
77 77
 	 * The SQL GROUP BY statment
78 78
 	 * @var string
79 79
 	*/
80
-    private $groupBy             = null;
80
+    private $groupBy = null;
81 81
 	
82 82
 	/**
83 83
 	 * The SQL HAVING statment
84 84
 	 * @var string
85 85
 	*/
86
-    private $having              = null;
86
+    private $having = null;
87 87
 	
88 88
 	/**
89 89
 	 * The number of rows returned by the last query
90 90
 	 * @var int
91 91
 	*/
92
-    private $numRows             = 0;
92
+    private $numRows = 0;
93 93
 	
94 94
 	/**
95 95
 	 * The last insert id for the primary key column that have auto increment or sequence
96 96
 	 * @var mixed
97 97
 	*/
98
-    private $insertId            = null;
98
+    private $insertId = null;
99 99
 	
100 100
 	/**
101 101
 	 * The full SQL query statment after build for each command
102 102
 	 * @var string
103 103
 	*/
104
-    private $query               = null;
104
+    private $query = null;
105 105
 	
106 106
 	/**
107 107
 	 * The error returned for the last query
108 108
 	 * @var string
109 109
 	*/
110
-    private $error               = null;
110
+    private $error = null;
111 111
 	
112 112
 	/**
113 113
 	 * The result returned for the last query
114 114
 	 * @var mixed
115 115
 	*/
116
-    private $result              = array();
116
+    private $result = array();
117 117
 	
118 118
 	/**
119 119
 	 * The prefix used in each database table
120 120
 	 * @var string
121 121
 	*/
122
-    private $prefix              = null;
122
+    private $prefix = null;
123 123
 	
124 124
 	/**
125 125
 	 * The list of SQL valid operators
126 126
 	 * @var array
127 127
 	*/
128
-    private $operatorList        = array('=','!=','<','>','<=','>=','<>');
128
+    private $operatorList = array('=', '!=', '<', '>', '<=', '>=', '<>');
129 129
     
130 130
 	/**
131 131
 	 * The cache default time to live in second. 0 means no need to use the cache feature
132 132
 	 * @var int
133 133
 	*/
134
-	private $cacheTtl              = 0;
134
+	private $cacheTtl = 0;
135 135
 	
136 136
 	/**
137 137
 	 * The cache current time to live. 0 means no need to use the cache feature
138 138
 	 * @var int
139 139
 	*/
140
-    private $temporaryCacheTtl   = 0;
140
+    private $temporaryCacheTtl = 0;
141 141
 	
142 142
 	/**
143 143
 	 * The number of executed query for the current request
144 144
 	 * @var int
145 145
 	*/
146
-    private $queryCount          = 0;
146
+    private $queryCount = 0;
147 147
 	
148 148
 	/**
149 149
 	 * The default data to be used in the statments query INSERT, UPDATE
150 150
 	 * @var array
151 151
 	*/
152
-    private $data                = array();
152
+    private $data = array();
153 153
 	
154 154
 	/**
155 155
 	 * The database configuration
156 156
 	 * @var array
157 157
 	*/
158
-    private $config              = array();
158
+    private $config = array();
159 159
 	
160 160
 	/**
161 161
 	 * The logger instance
162 162
 	 * @var Log
163 163
 	 */
164
-    private $logger              = null;
164
+    private $logger = null;
165 165
 
166 166
 
167 167
     /**
168 168
     * The cache instance
169 169
     * @var CacheInterface
170 170
     */
171
-    private $cacheInstance       = null;
171
+    private $cacheInstance = null;
172 172
 
173 173
      /**
174 174
     * The benchmark instance
175 175
     * @var Benchmark
176 176
     */
177
-    private $benchmarkInstance   = null;
177
+    private $benchmarkInstance = null;
178 178
 
179 179
 
180 180
     /**
@@ -182,25 +182,25 @@  discard block
 block discarded – undo
182 182
      * @param array $overwriteConfig the config to overwrite with the config set in database.php
183 183
      * @param object $logger the log instance
184 184
      */
185
-    public function __construct($overwriteConfig = array(), Log $logger = null){
185
+    public function __construct($overwriteConfig = array(), Log $logger = null) {
186 186
         /**
187 187
          * instance of the Log class
188 188
          */
189
-        if(is_object($logger)){
189
+        if (is_object($logger)) {
190 190
           $this->logger = $logger;
191 191
         }
192
-        else{
193
-            $this->logger =& class_loader('Log', 'classes');
192
+        else {
193
+            $this->logger = & class_loader('Log', 'classes');
194 194
             $this->logger->setLogger('Library::Database');
195 195
         }
196 196
 
197 197
         $db = array();
198
-      	if(file_exists(CONFIG_PATH . 'database.php')){
198
+      	if (file_exists(CONFIG_PATH . 'database.php')) {
199 199
           //here don't use require_once because somewhere user can create database instance directly
200 200
       	  require CONFIG_PATH . 'database.php';
201 201
         }
202 202
           
203
-				if(! empty($overwriteConfig)){
203
+				if (!empty($overwriteConfig)) {
204 204
 				  $db = array_merge($db, $overwriteConfig);
205 205
 				}
206 206
 				$config['driver']    = isset($db['driver']) ? $db['driver'] : 'mysql';
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 				$config['collation'] = isset($db['collation']) ? $db['collation'] : 'utf8_general_ci';
213 213
 				$config['prefix']    = isset($db['prefix']) ? $db['prefix'] : '';
214 214
         $port = '';
215
-        if(strstr($config['hostname'], ':')){
215
+        if (strstr($config['hostname'], ':')) {
216 216
           $p = explode(':', $config['hostname']);
217 217
           $port = isset($p[1]) ? $p[1] : '';
218 218
         }
219
-				$config['port']      = $port;
219
+				$config['port'] = $port;
220 220
 				
221 221
 		  	$this->setDatabaseConfiguration($config);
222 222
 
@@ -227,20 +227,20 @@  discard block
 block discarded – undo
227 227
      * This is used to connect to database
228 228
      * @return bool 
229 229
      */
230
-    public function connect(){
230
+    public function connect() {
231 231
       $config = $this->getDatabaseConfiguration();
232
-      if(! empty($config)){
233
-        try{
232
+      if (!empty($config)) {
233
+        try {
234 234
             $dsn = '';
235
-            if($config['driver'] == 'mysql' || $config['driver'] == '' || $config['driver'] == 'pgsql'){
235
+            if ($config['driver'] == 'mysql' || $config['driver'] == '' || $config['driver'] == 'pgsql') {
236 236
                 $dsn = $config['driver'] . ':host=' . $config['hostname'] . ';'
237 237
                 . (($config['port']) != '' ? 'port=' . $config['port'] . ';' : '')
238 238
                 . 'dbname=' . $config['database'];
239 239
             }
240
-            else if ($config['driver'] == 'sqlite'){
240
+            else if ($config['driver'] == 'sqlite') {
241 241
               $dsn = 'sqlite:' . $config['database'];
242 242
             }
243
-            else if($config['driver'] == 'oracle'){
243
+            else if ($config['driver'] == 'oracle') {
244 244
               $dsn = 'oci:dbname=' . $config['host'] . '/' . $config['database'];
245 245
             }
246 246
             
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
251 251
             return true;
252 252
           }
253
-          catch (PDOException $e){
253
+          catch (PDOException $e) {
254 254
             $this->logger->fatal($e->getMessage());
255 255
             show_error('Cannot connect to Database.');
256 256
             return false;
257 257
           }
258 258
       }
259
-      else{
259
+      else {
260 260
         show_error('Database configuration is not set.');
261 261
         return false;
262 262
       }
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
      * @param  string|array $table the table name or array of table list
268 268
      * @return object        the current Database instance
269 269
      */
270
-    public function from($table){
271
-      if(is_array($table)){
270
+    public function from($table) {
271
+      if (is_array($table)) {
272 272
         $froms = '';
273
-        foreach($table as $key){
273
+        foreach ($table as $key) {
274 274
           $froms .= $this->prefix . $key . ', ';
275 275
         }
276 276
         $this->from = rtrim($froms, ', ');
277 277
       }
278
-      else{
278
+      else {
279 279
         $this->from = $this->prefix . $table;
280 280
       }
281 281
       return $this;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      * @param  string|array $fields the field name or array of field list
287 287
      * @return object        the current Database instance
288 288
      */
289
-    public function select($fields){
289
+    public function select($fields) {
290 290
       $select = (is_array($fields) ? implode(', ', $fields) : $fields);
291 291
       $this->select = ($this->select == '*' ? $select : $this->select . ', ' . $select);
292 292
       return $this;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      * @param  string $field the field name to distinct
298 298
      * @return object        the current Database instance
299 299
      */
300
-    public function distinct($field){
300
+    public function distinct($field) {
301 301
       $distinct = ' DISTINCT ' . $field;
302 302
       $this->select = ($this->select == '*' ? $distinct : $this->select . ', ' . $distinct);
303 303
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      * @param  string $name  if is not null represent the alias used for this field in the result
311 311
      * @return object        the current Database instance
312 312
      */
313
-    public function max($field, $name = null){
313
+    public function max($field, $name = null) {
314 314
       $func = 'MAX(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
315 315
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
316 316
       return $this;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      * @param  string $name  if is not null represent the alias used for this field in the result
323 323
      * @return object        the current Database instance
324 324
      */
325
-    public function min($field, $name = null){
325
+    public function min($field, $name = null) {
326 326
       $func = 'MIN(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
327 327
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
328 328
       return $this;
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @param  string $name  if is not null represent the alias used for this field in the result
335 335
      * @return object        the current Database instance
336 336
      */
337
-    public function sum($field, $name = null){
337
+    public function sum($field, $name = null) {
338 338
       $func = 'SUM(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
339 339
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
340 340
       return $this;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      * @param  string $name  if is not null represent the alias used for this field in the result
347 347
      * @return object        the current Database instance
348 348
      */
349
-    public function count($field = '*', $name = null){
349
+    public function count($field = '*', $name = null) {
350 350
       $func = 'COUNT(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
351 351
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
352 352
       return $this;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
      * @param  string $name  if is not null represent the alias used for this field in the result
359 359
      * @return object        the current Database instance
360 360
      */
361
-    public function avg($field, $name = null){
361
+    public function avg($field, $name = null) {
362 362
       $func = 'AVG(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
363 363
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
364 364
       return $this;
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
      * @param  string $type   the type of join (INNER, LEFT, RIGHT)
374 374
      * @return object        the current Database instance
375 375
      */
376
-    public function join($table, $field1 = null, $op = null, $field2 = null, $type = ''){
376
+    public function join($table, $field1 = null, $op = null, $field2 = null, $type = '') {
377 377
       $on = $field1;
378 378
       $table = $this->prefix . $table;
379
-      if(! is_null($op)){
380
-        $on = (! in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
379
+      if (!is_null($op)) {
380
+        $on = (!in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
381 381
       }
382
-      if (is_null($this->join)){
382
+      if (is_null($this->join)) {
383 383
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
384 384
       }
385
-      else{
385
+      else {
386 386
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
387 387
       }
388 388
       return $this;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
      * @see  Database::join()
394 394
      * @return object        the current Database instance
395 395
      */
396
-    public function innerJoin($table, $field1, $op = null, $field2 = ''){
396
+    public function innerJoin($table, $field1, $op = null, $field2 = '') {
397 397
       return $this->join($table, $field1, $op, $field2, 'INNER ');
398 398
     }
399 399
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      * @see  Database::join()
403 403
      * @return object        the current Database instance
404 404
      */
405
-    public function leftJoin($table, $field1, $op = null, $field2 = ''){
405
+    public function leftJoin($table, $field1, $op = null, $field2 = '') {
406 406
       return $this->join($table, $field1, $op, $field2, 'LEFT ');
407 407
 	}
408 408
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      * @see  Database::join()
412 412
      * @return object        the current Database instance
413 413
      */
414
-    public function rightJoin($table, $field1, $op = null, $field2 = ''){
414
+    public function rightJoin($table, $field1, $op = null, $field2 = '') {
415 415
       return $this->join($table, $field1, $op, $field2, 'RIGHT ');
416 416
     }
417 417
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      * @see  Database::join()
421 421
      * @return object        the current Database instance
422 422
      */
423
-    public function fullOuterJoin($table, $field1, $op = null, $field2 = ''){
423
+    public function fullOuterJoin($table, $field1, $op = null, $field2 = '') {
424 424
     	return $this->join($table, $field1, $op, $field2, 'FULL OUTER ');
425 425
     }
426 426
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      * @see  Database::join()
430 430
      * @return object        the current Database instance
431 431
      */
432
-    public function leftOuterJoin($table, $field1, $op = null, $field2 = ''){
432
+    public function leftOuterJoin($table, $field1, $op = null, $field2 = '') {
433 433
       return $this->join($table, $field1, $op, $field2, 'LEFT OUTER ');
434 434
     }
435 435
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      * @see  Database::join()
439 439
      * @return object        the current Database instance
440 440
      */
441
-    public function rightOuterJoin($table, $field1, $op = null, $field2 = ''){
441
+    public function rightOuterJoin($table, $field1, $op = null, $field2 = '') {
442 442
       return $this->join($table, $field1, $op, $field2, 'RIGHT OUTER ');
443 443
     }
444 444
 
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
449 449
      * @return object        the current Database instance
450 450
      */
451
-    public function whereIsNull($field, $andOr = 'AND'){
452
-      if(is_array($field)){
453
-        foreach($field as $f){
451
+    public function whereIsNull($field, $andOr = 'AND') {
452
+      if (is_array($field)) {
453
+        foreach ($field as $f) {
454 454
         	$this->whereIsNull($f, $andOr);
455 455
         }
456 456
       }
457
-      else{
458
-        if (! $this->where){
459
-          $this->where = $field.' IS NULL ';
457
+      else {
458
+        if (!$this->where) {
459
+          $this->where = $field . ' IS NULL ';
460 460
         }
461
-        else{
462
-            $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NULL ';
461
+        else {
462
+            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' IS NULL ';
463 463
           }
464 464
       }
465 465
       return $this;
@@ -471,18 +471,18 @@  discard block
 block discarded – undo
471 471
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
472 472
      * @return object        the current Database instance
473 473
      */
474
-    public function whereIsNotNull($field, $andOr = 'AND'){
475
-      if(is_array($field)){
476
-        foreach($field as $f){
474
+    public function whereIsNotNull($field, $andOr = 'AND') {
475
+      if (is_array($field)) {
476
+        foreach ($field as $f) {
477 477
           $this->whereIsNotNull($f, $andOr);
478 478
         }
479 479
       }
480
-      else{
481
-        if (! $this->where){
482
-          $this->where = $field.' IS NOT NULL ';
480
+      else {
481
+        if (!$this->where) {
482
+          $this->where = $field . ' IS NOT NULL ';
483 483
         }
484
-        else{
485
-            $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NOT NULL ';
484
+        else {
485
+            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' IS NOT NULL ';
486 486
           }
487 487
       }
488 488
       return $this;
@@ -498,24 +498,24 @@  discard block
 block discarded – undo
498 498
      * @param  boolean $escape whether to escape or not the $val
499 499
      * @return object        the current Database instance
500 500
      */
501
-    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true){
502
-      if (is_array($where)){
501
+    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true) {
502
+      if (is_array($where)) {
503 503
         $_where = array();
504
-        foreach ($where as $column => $data){
505
-          if(is_null($data)){
504
+        foreach ($where as $column => $data) {
505
+          if (is_null($data)) {
506 506
             $data = '';
507 507
           }
508 508
           $_where[] = $type . $column . '=' . ($escape ? $this->escape($data) : $data);
509 509
         }
510
-        $where = implode(' '.$andOr.' ', $_where);
510
+        $where = implode(' ' . $andOr . ' ', $_where);
511 511
       }
512
-      else{
513
-        if(is_array($op)){
512
+      else {
513
+        if (is_array($op)) {
514 514
           $x = explode('?', $where);
515 515
           $w = '';
516
-          foreach($x as $k => $v){
517
-            if(! empty($v)){
518
-                if(isset($op[$k]) && is_null($op[$k])){
516
+          foreach ($x as $k => $v) {
517
+            if (!empty($v)) {
518
+                if (isset($op[$k]) && is_null($op[$k])) {
519 519
                   $op[$k] = '';
520 520
                 }
521 521
                 $w .= $type . $v . (isset($op[$k]) ? ($escape ? $this->escape($op[$k]) : $op[$k]) : '');
@@ -523,28 +523,28 @@  discard block
 block discarded – undo
523 523
           }
524 524
           $where = $w;
525 525
         }
526
-        else if (! in_array((string)$op, $this->operatorList)){
527
-          if(is_null($op)){
526
+        else if (!in_array((string) $op, $this->operatorList)) {
527
+          if (is_null($op)) {
528 528
             $op = '';
529 529
           }
530 530
         	$where = $type . $where . ' = ' . ($escape ? $this->escape($op) : $op);
531 531
         }
532
-        else{
533
-          if(is_null($val)){
532
+        else {
533
+          if (is_null($val)) {
534 534
             $val = '';
535 535
           }
536 536
         	$where = $type . $where . $op . ($escape ? $this->escape($val) : $val);
537 537
         }
538 538
       }
539
-      if (is_null($this->where)){
539
+      if (is_null($this->where)) {
540 540
         $this->where = $where;
541 541
       }
542
-      else{
543
-        if(substr($this->where, -1) == '('){
542
+      else {
543
+        if (substr($this->where, -1) == '(') {
544 544
           $this->where = $this->where . ' ' . $where;
545 545
         }
546
-        else{
547
-          $this->where = $this->where . ' '.$andOr.' ' . $where;
546
+        else {
547
+          $this->where = $this->where . ' ' . $andOr . ' ' . $where;
548 548
         }
549 549
       }
550 550
       return $this;
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
      * @see  Database::where()
556 556
      * @return object        the current Database instance
557 557
      */
558
-    public function orWhere($where, $op = null, $val = null, $escape = true){
558
+    public function orWhere($where, $op = null, $val = null, $escape = true) {
559 559
       return $this->where($where, $op, $val, '', 'OR', $escape);
560 560
     }
561 561
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
      * @see  Database::where()
566 566
      * @return object        the current Database instance
567 567
      */
568
-    public function notWhere($where, $op = null, $val = null, $escape = true){
568
+    public function notWhere($where, $op = null, $val = null, $escape = true) {
569 569
       return $this->where($where, $op, $val, 'NOT ', 'AND', $escape);
570 570
     }
571 571
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
      * @see  Database::where()
575 575
      * @return object        the current Database instance
576 576
      */
577
-    public function orNotWhere($where, $op = null, $val = null, $escape = true){
577
+    public function orNotWhere($where, $op = null, $val = null, $escape = true) {
578 578
     	return $this->where($where, $op, $val, 'NOT ', 'OR', $escape);
579 579
     }
580 580
 
@@ -584,15 +584,15 @@  discard block
 block discarded – undo
584 584
      * @param  string $andOr the multiple conditions separator (AND, OR, etc.)
585 585
      * @return object        the current Database instance
586 586
      */
587
-    public function groupStart($type = '', $andOr = ' AND'){
588
-      if (is_null($this->where)){
587
+    public function groupStart($type = '', $andOr = ' AND') {
588
+      if (is_null($this->where)) {
589 589
         $this->where = $type . ' (';
590 590
       }
591
-      else{
592
-          if(substr($this->where, -1) == '('){
591
+      else {
592
+          if (substr($this->where, -1) == '(') {
593 593
             $this->where .= $type . ' (';
594 594
           }
595
-          else{
595
+          else {
596 596
           	$this->where .= $andOr . ' ' . $type . ' (';
597 597
           }
598 598
       }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
      * @see  Database::groupStart()
605 605
      * @return object        the current Database instance
606 606
      */
607
-    public function notGroupStart(){
607
+    public function notGroupStart() {
608 608
       return $this->groupStart('NOT');
609 609
     }
610 610
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      * @see  Database::groupStart()
614 614
      * @return object        the current Database instance
615 615
      */
616
-    public function orGroupStart(){
616
+    public function orGroupStart() {
617 617
       return $this->groupStart('', ' OR');
618 618
     }
619 619
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
      * @see  Database::groupStart()
623 623
      * @return object        the current Database instance
624 624
      */
625
-    public function orNotGroupStart(){
625
+    public function orNotGroupStart() {
626 626
       return $this->groupStart('NOT', ' OR');
627 627
     }
628 628
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
      * Close the parenthesis for the grouped SQL
631 631
      * @return object        the current Database instance
632 632
      */
633
-    public function groupEnd(){
633
+    public function groupEnd() {
634 634
       $this->where .= ')';
635 635
       return $this;
636 636
     }
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
      * @param  boolean $escape whether to escape or not the values
645 645
      * @return object        the current Database instance
646 646
      */
647
-    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true){
648
-      if (is_array($keys)){
647
+    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true) {
648
+      if (is_array($keys)) {
649 649
         $_keys = array();
650
-        foreach ($keys as $k => $v){
651
-          if(is_null($v)){
650
+        foreach ($keys as $k => $v) {
651
+          if (is_null($v)) {
652 652
             $v = '';
653 653
           }
654 654
           $_keys[] = (is_numeric($v) ? $v : ($escape ? $this->escape($v) : $v));
655 655
         }
656 656
         $keys = implode(', ', $_keys);
657
-        if (is_null($this->where)){
657
+        if (is_null($this->where)) {
658 658
           $this->where = $field . ' ' . $type . 'IN (' . $keys . ')';
659 659
         }
660
-        else{
661
-          if(substr($this->where, -1) == '('){
662
-            $this->where = $this->where . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
660
+        else {
661
+          if (substr($this->where, -1) == '(') {
662
+            $this->where = $this->where . ' ' . $field . ' ' . $type . 'IN (' . $keys . ')';
663 663
           }
664
-          else{
665
-            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
664
+          else {
665
+            $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'IN (' . $keys . ')';
666 666
           }
667 667
         }
668 668
       }
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
      * @see  Database::in()
675 675
      * @return object        the current Database instance
676 676
      */
677
-    public function notIn($field, array $keys, $escape = true){
677
+    public function notIn($field, array $keys, $escape = true) {
678 678
       return $this->in($field, $keys, 'NOT ', 'AND', $escape);
679 679
     }
680 680
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
      * @see  Database::in()
684 684
      * @return object        the current Database instance
685 685
      */
686
-    public function orIn($field, array $keys, $escape = true){
686
+    public function orIn($field, array $keys, $escape = true) {
687 687
       return $this->in($field, $keys, '', 'OR', $escape);
688 688
     }
689 689
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
      * @see  Database::in()
693 693
      * @return object        the current Database instance
694 694
      */
695
-    public function orNotIn($field, array $keys, $escape = true){
695
+    public function orNotIn($field, array $keys, $escape = true) {
696 696
       return $this->in($field, $keys, 'NOT ', 'OR', $escape);
697 697
     }
698 698
 
@@ -706,21 +706,21 @@  discard block
 block discarded – undo
706 706
      * @param  boolean $escape whether to escape or not the values
707 707
      * @return object        the current Database instance
708 708
      */
709
-    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true){
710
-      if(is_null($value1)){
709
+    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true) {
710
+      if (is_null($value1)) {
711 711
         $value1 = '';
712 712
       }
713
-      if(is_null($value2)){
713
+      if (is_null($value2)) {
714 714
         $value2 = '';
715 715
       }
716
-      if (is_null($this->where)){
716
+      if (is_null($this->where)) {
717 717
       	$this->where = $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
718 718
       }
719
-      else{
720
-        if(substr($this->where, -1) == '('){
719
+      else {
720
+        if (substr($this->where, -1) == '(') {
721 721
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
722 722
         }
723
-        else{
723
+        else {
724 724
           $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
725 725
         }
726 726
       }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
      * @see  Database::between()
733 733
      * @return object        the current Database instance
734 734
      */
735
-    public function notBetween($field, $value1, $value2, $escape = true){
735
+    public function notBetween($field, $value1, $value2, $escape = true) {
736 736
       return $this->between($field, $value1, $value2, 'NOT ', 'AND', $escape);
737 737
     }
738 738
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      * @see  Database::between()
742 742
      * @return object        the current Database instance
743 743
      */
744
-    public function orBetween($field, $value1, $value2, $escape = true){
744
+    public function orBetween($field, $value1, $value2, $escape = true) {
745 745
       return $this->between($field, $value1, $value2, '', 'OR', $escape);
746 746
     }
747 747
 
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
      * @see  Database::between()
751 751
      * @return object        the current Database instance
752 752
      */
753
-    public function orNotBetween($field, $value1, $value2, $escape = true){
753
+    public function orNotBetween($field, $value1, $value2, $escape = true) {
754 754
       return $this->between($field, $value1, $value2, 'NOT ', 'OR', $escape);
755 755
     }
756 756
 
@@ -763,20 +763,20 @@  discard block
 block discarded – undo
763 763
      * @param  boolean $escape whether to escape or not the values
764 764
      * @return object        the current Database instance
765 765
      */
766
-    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true){
767
-      if(is_null($data)){
766
+    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true) {
767
+      if (is_null($data)) {
768 768
         $data = '';
769 769
       }
770 770
       $like = $escape ? $this->escape($data) : $data;
771
-      if (is_null($this->where)){
771
+      if (is_null($this->where)) {
772 772
         $this->where = $field . ' ' . $type . 'LIKE ' . $like;
773 773
       }
774
-      else{
775
-        if(substr($this->where, -1) == '('){
774
+      else {
775
+        if (substr($this->where, -1) == '(') {
776 776
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'LIKE ' . $like;
777 777
         }
778
-        else{
779
-          $this->where = $this->where . ' '.$andOr.' ' . $field . ' ' . $type . 'LIKE ' . $like;
778
+        else {
779
+          $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'LIKE ' . $like;
780 780
         }
781 781
       }
782 782
       return $this;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
      * @see  Database::like()
788 788
      * @return object        the current Database instance
789 789
      */
790
-    public function orLike($field, $data, $escape = true){
790
+    public function orLike($field, $data, $escape = true) {
791 791
       return $this->like($field, $data, '', 'OR', $escape);
792 792
     }
793 793
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
      * @see  Database::like()
797 797
      * @return object        the current Database instance
798 798
      */
799
-    public function notLike($field, $data, $escape = true){
799
+    public function notLike($field, $data, $escape = true) {
800 800
       return $this->like($field, $data, 'NOT ', 'AND', $escape);
801 801
     }
802 802
 
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      * @see  Database::like()
806 806
      * @return object        the current Database instance
807 807
      */
808
-    public function orNotLike($field, $data, $escape = true){
808
+    public function orNotLike($field, $data, $escape = true) {
809 809
       return $this->like($field, $data, 'NOT ', 'OR', $escape);
810 810
     }
811 811
 
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
      * @param  int $limitEnd the limit count
817 817
      * @return object        the current Database instance
818 818
      */
819
-    public function limit($limit, $limitEnd = null){
820
-      if(is_null($limit)){
819
+    public function limit($limit, $limitEnd = null) {
820
+      if (is_null($limit)) {
821 821
         return;
822 822
       }
823
-      if (! is_null($limitEnd)){
823
+      if (!is_null($limitEnd)) {
824 824
         $this->limit = $limit . ', ' . $limitEnd;
825 825
       }
826
-      else{
826
+      else {
827 827
         $this->limit = $limit;
828 828
       }
829 829
       return $this;
@@ -835,16 +835,16 @@  discard block
 block discarded – undo
835 835
      * @param  string $orderDir the order direction (ASC or DESC)
836 836
      * @return object        the current Database instance
837 837
      */
838
-    public function orderBy($orderBy, $orderDir = ' ASC'){
839
-      if (! is_null($orderDir)){
840
-        $this->orderBy = ! $this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
838
+    public function orderBy($orderBy, $orderDir = ' ASC') {
839
+      if (!is_null($orderDir)) {
840
+        $this->orderBy = !$this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
841 841
       }
842
-      else{
843
-        if(stristr($orderBy, ' ') || $orderBy == 'rand()'){
844
-          $this->orderBy = ! $this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy;
842
+      else {
843
+        if (stristr($orderBy, ' ') || $orderBy == 'rand()') {
844
+          $this->orderBy = !$this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy;
845 845
         }
846
-        else{
847
-          $this->orderBy = ! $this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC');
846
+        else {
847
+          $this->orderBy = !$this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC');
848 848
         }
849 849
       }
850 850
       return $this;
@@ -855,11 +855,11 @@  discard block
 block discarded – undo
855 855
      * @param  string|array $field the field name used or array of field list
856 856
      * @return object        the current Database instance
857 857
      */
858
-    public function groupBy($field){
859
-      if(is_array($field)){
858
+    public function groupBy($field) {
859
+      if (is_array($field)) {
860 860
         $this->groupBy = implode(', ', $field);
861 861
       }
862
-      else{
862
+      else {
863 863
         $this->groupBy = $field;
864 864
       }
865 865
       return $this;
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
      * @param  boolean $escape whether to escape or not the values
874 874
      * @return object        the current Database instance
875 875
      */
876
-    public function having($field, $op = null, $val = null, $escape = true){
877
-      if(is_array($op)){
876
+    public function having($field, $op = null, $val = null, $escape = true) {
877
+      if (is_array($op)) {
878 878
         $x = explode('?', $field);
879 879
         $w = '';
880
-        foreach($x as $k => $v){
881
-  	      if(!empty($v)){
882
-            if(isset($op[$k]) && is_null($op[$k])){
880
+        foreach ($x as $k => $v) {
881
+  	      if (!empty($v)) {
882
+            if (isset($op[$k]) && is_null($op[$k])) {
883 883
               $op[$k] = '';
884 884
             }
885 885
   	      	$w .= $v . (isset($op[$k]) ? ($escape ? $this->escape($op[$k]) : $op[$k]) : '');
@@ -887,14 +887,14 @@  discard block
 block discarded – undo
887 887
       	}
888 888
         $this->having = $w;
889 889
       }
890
-      else if (! in_array($op, $this->operatorList)){
891
-        if(is_null($op)){
890
+      else if (!in_array($op, $this->operatorList)) {
891
+        if (is_null($op)) {
892 892
           $op = '';
893 893
         }
894 894
         $this->having = $field . ' > ' . ($escape ? $this->escape($op) : $op);
895 895
       }
896
-      else{
897
-        if(is_null($val)){
896
+      else {
897
+        if (is_null($val)) {
898 898
           $val = '';
899 899
         }
900 900
         $this->having = $field . ' ' . $op . ' ' . ($escape ? $this->escape($val) : $val);
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
      * Return the number of rows returned by the current query
907 907
      * @return int
908 908
      */
909
-    public function numRows(){
909
+    public function numRows() {
910 910
       return $this->numRows;
911 911
     }
912 912
 
@@ -914,15 +914,15 @@  discard block
 block discarded – undo
914 914
      * Return the last insert id value
915 915
      * @return mixed
916 916
      */
917
-    public function insertId(){
917
+    public function insertId() {
918 918
       return $this->insertId;
919 919
     }
920 920
 
921 921
     /**
922 922
      * Show an error got from the current query (SQL command synthax error, database driver returned error, etc.)
923 923
      */
924
-    public function error(){
925
-  		if($this->error){
924
+    public function error() {
925
+  		if ($this->error) {
926 926
   			show_error('Query: "' . $this->query . '" Error: ' . $this->error, 'Database Error');
927 927
   		}
928 928
     }
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
      * If is string will determine the result type "array" or "object"
934 934
      * @return mixed       the query SQL string or the record result
935 935
      */
936
-    public function get($returnSQLQueryOrResultType = false){
936
+    public function get($returnSQLQueryOrResultType = false) {
937 937
       $this->limit = 1;
938 938
       $query = $this->getAll(true);
939
-      if($returnSQLQueryOrResultType === true){
939
+      if ($returnSQLQueryOrResultType === true) {
940 940
         return $query;
941 941
       }
942
-      else{
943
-        return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) );
942
+      else {
943
+        return $this->query($query, false, (($returnSQLQueryOrResultType == 'array') ? true : false));
944 944
       }
945 945
     }
946 946
 
@@ -950,37 +950,37 @@  discard block
 block discarded – undo
950 950
      * If is string will determine the result type "array" or "object"
951 951
      * @return mixed       the query SQL string or the record result
952 952
      */
953
-    public function getAll($returnSQLQueryOrResultType = false){
953
+    public function getAll($returnSQLQueryOrResultType = false) {
954 954
       $query = 'SELECT ' . $this->select . ' FROM ' . $this->from;
955
-      if (! is_null($this->join)){
955
+      if (!is_null($this->join)) {
956 956
         $query .= $this->join;
957 957
       }
958 958
 	  
959
-      if (! is_null($this->where)){
959
+      if (!is_null($this->where)) {
960 960
         $query .= ' WHERE ' . $this->where;
961 961
       }
962 962
 
963
-      if (! is_null($this->groupBy)){
963
+      if (!is_null($this->groupBy)) {
964 964
         $query .= ' GROUP BY ' . $this->groupBy;
965 965
       }
966 966
 
967
-      if (! is_null($this->having)){
967
+      if (!is_null($this->having)) {
968 968
         $query .= ' HAVING ' . $this->having;
969 969
       }
970 970
 
971
-      if (! is_null($this->orderBy)){
971
+      if (!is_null($this->orderBy)) {
972 972
           $query .= ' ORDER BY ' . $this->orderBy;
973 973
       }
974 974
 
975
-      if(! is_null($this->limit)){
975
+      if (!is_null($this->limit)) {
976 976
       	$query .= ' LIMIT ' . $this->limit;
977 977
       }
978 978
 	  
979
-	  if($returnSQLQueryOrResultType === true){
979
+	  if ($returnSQLQueryOrResultType === true) {
980 980
     	return $query;
981 981
       }
982
-      else{
983
-    	return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) );
982
+      else {
983
+    	return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false));
984 984
       }
985 985
     }
986 986
 
@@ -990,15 +990,15 @@  discard block
 block discarded – undo
990 990
      * @param  boolean $escape  whether to escape or not the values
991 991
      * @return mixed          the insert id of the new record or null
992 992
      */
993
-    public function insert($data = array(), $escape = true){
993
+    public function insert($data = array(), $escape = true) {
994 994
       $column = array();
995 995
       $val = array();
996
-      if(! $data && $this->getData()){
996
+      if (!$data && $this->getData()) {
997 997
         $columns = array_keys($this->getData());
998 998
         $column = implode(',', $columns);
999 999
         $val = implode(', ', $this->getData());
1000 1000
       }
1001
-      else{
1001
+      else {
1002 1002
         $columns = array_keys($data);
1003 1003
         $column = implode(',', $columns);
1004 1004
         $val = implode(', ', ($escape ? array_map(array($this, 'escape'), $data) : $data));
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
       $query = 'INSERT INTO ' . $this->from . ' (' . $column . ') VALUES (' . $val . ')';
1008 1008
       $query = $this->query($query);
1009 1009
 
1010
-      if ($query){
1011
-        if(! $this->pdo){
1010
+      if ($query) {
1011
+        if (!$this->pdo) {
1012 1012
           $this->connect();
1013 1013
         }
1014 1014
         $this->insertId = $this->pdo->lastInsertId();
1015 1015
         return $this->insertId();
1016 1016
       }
1017
-      else{
1017
+      else {
1018 1018
 		  return false;
1019 1019
       }
1020 1020
     }
@@ -1025,29 +1025,29 @@  discard block
 block discarded – undo
1025 1025
      * @param  boolean $escape  whether to escape or not the values
1026 1026
      * @return mixed          the update status
1027 1027
      */
1028
-    public function update($data = array(), $escape = true){
1028
+    public function update($data = array(), $escape = true) {
1029 1029
       $query = 'UPDATE ' . $this->from . ' SET ';
1030 1030
       $values = array();
1031
-      if(! $data && $this->getData()){
1032
-        foreach ($this->getData() as $column => $val){
1031
+      if (!$data && $this->getData()) {
1032
+        foreach ($this->getData() as $column => $val) {
1033 1033
           $values[] = $column . ' = ' . $val;
1034 1034
         }
1035 1035
       }
1036
-      else{
1037
-        foreach ($data as $column => $val){
1036
+      else {
1037
+        foreach ($data as $column => $val) {
1038 1038
           $values[] = $column . '=' . ($escape ? $this->escape($val) : $val);
1039 1039
         }
1040 1040
       }
1041 1041
       $query .= (is_array($data) ? implode(', ', $values) : $data);
1042
-      if (! is_null($this->where)){
1042
+      if (!is_null($this->where)) {
1043 1043
         $query .= ' WHERE ' . $this->where;
1044 1044
       }
1045 1045
 
1046
-      if (! is_null($this->orderBy)){
1046
+      if (!is_null($this->orderBy)) {
1047 1047
         $query .= ' ORDER BY ' . $this->orderBy;
1048 1048
       }
1049 1049
 
1050
-      if (! is_null($this->limit)){
1050
+      if (!is_null($this->limit)) {
1051 1051
         $query .= ' LIMIT ' . $this->limit;
1052 1052
       }
1053 1053
       return $this->query($query);
@@ -1057,22 +1057,22 @@  discard block
 block discarded – undo
1057 1057
      * Delete the record in database
1058 1058
      * @return mixed the delete status
1059 1059
      */
1060
-    public function delete(){
1060
+    public function delete() {
1061 1061
     	$query = 'DELETE FROM ' . $this->from;
1062 1062
 
1063
-    	if (! is_null($this->where)){
1063
+    	if (!is_null($this->where)) {
1064 1064
     		$query .= ' WHERE ' . $this->where;
1065 1065
       	}
1066 1066
 
1067
-    	if (! is_null($this->orderBy)){
1067
+    	if (!is_null($this->orderBy)) {
1068 1068
     	  $query .= ' ORDER BY ' . $this->orderBy;
1069 1069
       	}
1070 1070
 
1071
-    	if (! is_null($this->limit)){
1071
+    	if (!is_null($this->limit)) {
1072 1072
     		$query .= ' LIMIT ' . $this->limit;
1073 1073
       	}
1074 1074
 
1075
-    	if($query == 'DELETE FROM ' . $this->from){
1075
+    	if ($query == 'DELETE FROM ' . $this->from) {
1076 1076
     		$query = 'TRUNCATE TABLE ' . $this->from;
1077 1077
       	}
1078 1078
     	return $this->query($query);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
      * @param  boolean $array return the result as array
1086 1086
      * @return mixed         the query result
1087 1087
      */
1088
-    public function query($query, $all = true, $array = false){
1088
+    public function query($query, $all = true, $array = false) {
1089 1089
       $this->reset();
1090
-      if(is_array($all)){
1090
+      if (is_array($all)) {
1091 1091
         $x = explode('?', $query);
1092 1092
         $q = '';
1093
-        foreach($x as $k => $v){
1094
-          if(! empty($v)){
1093
+        foreach ($x as $k => $v) {
1094
+          if (!empty($v)) {
1095 1095
             $q .= $v . (isset($all[$k]) ? $this->escape($all[$k]) : '');
1096 1096
           }
1097 1097
         }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
       $this->query = preg_replace('/\s\s+|\t\t+/', ' ', trim($query));
1102 1102
       $sqlSELECTQuery = stristr($this->query, 'SELECT');
1103
-      $this->logger->info('Execute SQL query ['.$this->query.'], return type: ' . ($array?'ARRAY':'OBJECT') .', return as list: ' . ($all ? 'YES':'NO'));
1103
+      $this->logger->info('Execute SQL query [' . $this->query . '], return type: ' . ($array ? 'ARRAY' : 'OBJECT') . ', return as list: ' . ($all ? 'YES' : 'NO'));
1104 1104
       //cache expire time
1105 1105
   	  $cacheExpire = $this->temporaryCacheTtl;
1106 1106
   	  
@@ -1122,34 +1122,34 @@  discard block
 block discarded – undo
1122 1122
   	  //if can use cache feature for this query
1123 1123
   	  $dbCacheStatus = $cacheEnable && $cacheExpire > 0;
1124 1124
 	  
1125
-      if ($dbCacheStatus && $sqlSELECTQuery){
1125
+      if ($dbCacheStatus && $sqlSELECTQuery) {
1126 1126
         $this->logger->info('The cache is enabled for this query, try to get result from cache'); 
1127 1127
         $cacheKey = md5($query . $all . $array);
1128
-        if(is_object($this->cacheInstance)){
1128
+        if (is_object($this->cacheInstance)) {
1129 1129
           $cacheInstance = $this->cacheInstance;
1130 1130
         }
1131
-        else{
1131
+        else {
1132 1132
           $obj = & get_instance();
1133 1133
           $cacheInstance = $obj->cache;  
1134 1134
         }
1135 1135
         $cacheContent = $cacheInstance->get($cacheKey);        
1136 1136
       }
1137
-      else{
1137
+      else {
1138 1138
 		  $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database');
1139 1139
       }
1140 1140
 
1141
-      if(! $this->pdo){
1141
+      if (!$this->pdo) {
1142 1142
         $this->connect();
1143 1143
       }
1144 1144
       
1145
-      if (! $cacheContent && $sqlSELECTQuery){
1145
+      if (!$cacheContent && $sqlSELECTQuery) {
1146 1146
 		    //for database query execution time
1147 1147
         $benchmarkMarkerKey = md5($query . $all . $array);
1148 1148
         $bench = null;
1149
-        if(is_object($this->benchmarkInstance)){
1149
+        if (is_object($this->benchmarkInstance)) {
1150 1150
           $bench = $this->benchmarkInstance;
1151 1151
         }
1152
-        else{
1152
+        else {
1153 1153
           $obj = & get_instance();
1154 1154
           $bench = $obj->benchmark;  
1155 1155
         }
@@ -1160,52 +1160,52 @@  discard block
 block discarded – undo
1160 1160
     		//get response time for this query
1161 1161
         $responseTime = $bench->elapsedTime('DATABASE_QUERY_START(' . $benchmarkMarkerKey . ')', 'DATABASE_QUERY_END(' . $benchmarkMarkerKey . ')');
1162 1162
 	     	//TODO use the configuration value for the high response time currently is 1 second
1163
-        if($responseTime >= 1 ){
1164
-            $this->logger->warning('High response time while processing database query [' .$query. ']. The response time is [' .$responseTime. '] sec.');
1163
+        if ($responseTime >= 1) {
1164
+            $this->logger->warning('High response time while processing database query [' . $query . ']. The response time is [' . $responseTime . '] sec.');
1165 1165
         }
1166
-        if ($sqlQuery){
1166
+        if ($sqlQuery) {
1167 1167
           $this->numRows = $sqlQuery->rowCount();
1168
-          if (($this->numRows > 0)){
1168
+          if (($this->numRows > 0)) {
1169 1169
 		    	//if need return all result like list of record
1170
-            if ($all){
1170
+            if ($all) {
1171 1171
     				$this->result = ($array == false) ? $sqlQuery->fetchAll(PDO::FETCH_OBJ) : $sqlQuery->fetchAll(PDO::FETCH_ASSOC);
1172 1172
     		    }
1173
-            else{
1173
+            else {
1174 1174
 				        $this->result = ($array == false) ? $sqlQuery->fetch(PDO::FETCH_OBJ) : $sqlQuery->fetch(PDO::FETCH_ASSOC);
1175 1175
             }
1176 1176
           }
1177
-          if ($dbCacheStatus && $sqlSELECTQuery){
1178
-            $this->logger->info('Save the result for query [' .$this->query. '] into cache for future use');
1177
+          if ($dbCacheStatus && $sqlSELECTQuery) {
1178
+            $this->logger->info('Save the result for query [' . $this->query . '] into cache for future use');
1179 1179
             $cacheInstance->set($cacheKey, $this->result, $cacheExpire);
1180 1180
           }
1181 1181
         }
1182
-        else{
1182
+        else {
1183 1183
           $error = $this->pdo->errorInfo();
1184 1184
           $this->error = $error[2];
1185 1185
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1186 1186
           $this->error();
1187 1187
         }
1188 1188
       }
1189
-      else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){
1189
+      else if ((!$cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)) {
1190 1190
     		$queryStr = $this->pdo->query($this->query);
1191
-    		if($queryStr){
1191
+    		if ($queryStr) {
1192 1192
     			$this->result = $queryStr->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
1193 1193
     			$this->numRows = $queryStr->rowCount();
1194 1194
     		}
1195
-        if (! $this->result){
1195
+        if (!$this->result) {
1196 1196
           $error = $this->pdo->errorInfo();
1197 1197
           $this->error = $error[2];
1198 1198
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1199 1199
           $this->error();
1200 1200
         }
1201 1201
       }
1202
-      else{
1203
-        $this->logger->info('The result for query [' .$this->query. '] already cached use it');
1202
+      else {
1203
+        $this->logger->info('The result for query [' . $this->query . '] already cached use it');
1204 1204
         $this->result = $cacheContent;
1205 1205
 	     	$this->numRows = count($this->result);
1206 1206
       }
1207 1207
       $this->queryCount++;
1208
-      if(! $this->result){
1208
+      if (!$this->result) {
1209 1209
         $this->logger->info('No result where found for the query [' . $query . ']');
1210 1210
       }
1211 1211
       return $this->result;
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
      * @param integer $ttl the cache time to live in second
1217 1217
      * @return object        the current Database instance
1218 1218
      */
1219
-    public function setCache($ttl = 0){
1220
-      if($ttl > 0){
1219
+    public function setCache($ttl = 0) {
1220
+      if ($ttl > 0) {
1221 1221
         $this->cacheTtl = $ttl;
1222 1222
 		    $this->temporaryCacheTtl = $ttl;
1223 1223
       }
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 	 * @param  integer $ttl the cache time to live in second
1230 1230
 	 * @return object        the current Database instance
1231 1231
 	 */
1232
-	public function cached($ttl = 0){
1233
-      if($ttl > 0){
1232
+	public function cached($ttl = 0) {
1233
+      if ($ttl > 0) {
1234 1234
         $this->temporaryCacheTtl = $ttl;
1235 1235
       }
1236 1236
 	  return $this;
@@ -1241,11 +1241,11 @@  discard block
 block discarded – undo
1241 1241
      * @param  mixed $data the data to be escaped
1242 1242
      * @return mixed       the data after escaped
1243 1243
      */
1244
-    public function escape($data){
1245
-      if(is_null($data)){
1244
+    public function escape($data) {
1245
+      if (is_null($data)) {
1246 1246
         return null;
1247 1247
       }
1248
-      if(! $this->pdo){
1248
+      if (!$this->pdo) {
1249 1249
         $this->connect();
1250 1250
       }
1251 1251
       return $this->pdo->quote(trim($data));
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
      * Return the number query executed count for the current request
1256 1256
      * @return int
1257 1257
      */
1258
-    public function queryCount(){
1258
+    public function queryCount() {
1259 1259
       return $this->queryCount;
1260 1260
     }
1261 1261
 
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
      * Return the current query SQL string
1264 1264
      * @return string
1265 1265
      */
1266
-    public function getQuery(){
1266
+    public function getQuery() {
1267 1267
       return $this->query;
1268 1268
     }
1269 1269
 
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
      * Return the application database name
1272 1272
      * @return string
1273 1273
      */
1274
-    public function getDatabaseName(){
1274
+    public function getDatabaseName() {
1275 1275
       return $this->databaseName;
1276 1276
     }
1277 1277
 
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
      * Return the database configuration
1280 1280
      * @return array
1281 1281
      */
1282
-    public  function getDatabaseConfiguration(){
1282
+    public  function getDatabaseConfiguration() {
1283 1283
       return $this->config;
1284 1284
     }
1285 1285
 
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
      * set the database configuration
1288 1288
      * @param array $config the configuration
1289 1289
      */
1290
-    public function setDatabaseConfiguration(array $config){
1290
+    public function setDatabaseConfiguration(array $config) {
1291 1291
       $this->config = array_merge($this->config, $config);
1292 1292
       $this->prefix = $this->config['prefix'];
1293 1293
       $this->databaseName = $this->config['database'];
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
      * Return the PDO instance
1300 1300
      * @return PDO
1301 1301
      */
1302
-    public function getPdo(){
1302
+    public function getPdo() {
1303 1303
       return $this->pdo;
1304 1304
     }
1305 1305
 
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
      * Set the PDO instance
1308 1308
      * @param PDO $pdo the pdo object
1309 1309
      */
1310
-    public function setPdo(PDO $pdo){
1310
+    public function setPdo(PDO $pdo) {
1311 1311
       $this->pdo = $pdo;
1312 1312
       return $this;
1313 1313
     }
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
      * Return the Log instance
1318 1318
      * @return Log
1319 1319
      */
1320
-    public function getLogger(){
1320
+    public function getLogger() {
1321 1321
       return $this->logger;
1322 1322
     }
1323 1323
 
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
      * Set the log instance
1326 1326
      * @param Log $logger the log object
1327 1327
      */
1328
-    public function setLogger($logger){
1328
+    public function setLogger($logger) {
1329 1329
       $this->logger = $logger;
1330 1330
       return $this;
1331 1331
     }
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
      * Return the cache instance
1335 1335
      * @return CacheInterface
1336 1336
      */
1337
-    public function getCacheInstance(){
1337
+    public function getCacheInstance() {
1338 1338
       return $this->cacheInstance;
1339 1339
     }
1340 1340
 
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
      * Set the cache instance
1343 1343
      * @param CacheInterface $cache the cache object
1344 1344
      */
1345
-    public function setCacheInstance($cache){
1345
+    public function setCacheInstance($cache) {
1346 1346
       $this->cacheInstance = $cache;
1347 1347
       return $this;
1348 1348
     }
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
      * Return the benchmark instance
1352 1352
      * @return Benchmark
1353 1353
      */
1354
-    public function getBenchmark(){
1354
+    public function getBenchmark() {
1355 1355
       return $this->benchmarkInstance;
1356 1356
     }
1357 1357
 
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
      * Set the benchmark instance
1360 1360
      * @param Benchmark $cache the cache object
1361 1361
      */
1362
-    public function setBenchmark($benchmark){
1362
+    public function setBenchmark($benchmark) {
1363 1363
       $this->benchmarkInstance = $benchmark;
1364 1364
       return $this;
1365 1365
     }
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
      * Return the data to be used for insert, update, etc.
1369 1369
      * @return array
1370 1370
      */
1371
-    public function getData(){
1371
+    public function getData() {
1372 1372
       return $this->data;
1373 1373
     }
1374 1374
 
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
      * @param boolean $escape whether to escape or not the $value
1380 1380
      * @return object        the current Database instance
1381 1381
      */
1382
-    public function setData($key, $value, $escape = true){
1382
+    public function setData($key, $value, $escape = true) {
1383 1383
       $this->data[$key] = $escape ? $this->escape($value) : $value;
1384 1384
       return $this;
1385 1385
     }
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
   /**
1389 1389
    * Reset the database class attributs to the initail values before each query.
1390 1390
    */
1391
-  private function reset(){
1391
+  private function reset() {
1392 1392
     $this->select   = '*';
1393 1393
     $this->from     = null;
1394 1394
     $this->where    = null;
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
   /**
1409 1409
    * The class destructor
1410 1410
    */
1411
-  function __destruct(){
1411
+  function __destruct() {
1412 1412
     $this->pdo = null;
1413 1413
   }
1414 1414
 
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Controller{
27
+	class Controller {
28 28
 		
29 29
 		/**
30 30
 		 * The name of the module if this controller belong to an module
@@ -47,32 +47,32 @@  discard block
 block discarded – undo
47 47
 		/**
48 48
 		 * Class constructor
49 49
 		 */
50
-		public function __construct(){
51
-			$this->logger =& class_loader('Log', 'classes');
50
+		public function __construct() {
51
+			$this->logger = & class_loader('Log', 'classes');
52 52
 			$this->logger->setLogger('MainController');
53 53
 			self::$instance = & $this;
54 54
 			
55 55
 			$this->logger->debug('Adding the loaded classes to the super instance');
56
-			foreach (class_loaded() as $var => $class){
57
-				$this->$var =& class_loader($class);
56
+			foreach (class_loaded() as $var => $class) {
57
+				$this->$var = & class_loader($class);
58 58
 			}
59 59
 			
60 60
 			$this->logger->debug('Setting the cache handler instance');
61 61
 			//set cache handler instance
62
-			if(get_config('cache_enable', false)){
63
-				if(isset($this->{strtolower(get_config('cache_handler'))})){
62
+			if (get_config('cache_enable', false)) {
63
+				if (isset($this->{strtolower(get_config('cache_handler'))})) {
64 64
 					$this->cache = $this->{strtolower(get_config('cache_handler'))};
65 65
 					unset($this->{strtolower(get_config('cache_handler'))});
66 66
 				} 
67 67
 			}
68 68
 			$this->logger->debug('Loading the required classes into super instance');
69
-			$this->eventdispatcher =& class_loader('EventDispatcher', 'classes');
70
-			$this->loader =& class_loader('Loader', 'classes');
71
-			$this->lang =& class_loader('Lang', 'classes');
72
-			$this->request =& class_loader('Request', 'classes');
69
+			$this->eventdispatcher = & class_loader('EventDispatcher', 'classes');
70
+			$this->loader = & class_loader('Loader', 'classes');
71
+			$this->lang = & class_loader('Lang', 'classes');
72
+			$this->request = & class_loader('Request', 'classes');
73 73
 			//dispatch the request instance created event
74 74
 			$this->eventdispatcher->dispatch('REQUEST_CREATED');
75
-			$this->response =& class_loader('Response', 'classes', 'classes');
75
+			$this->response = & class_loader('Response', 'classes', 'classes');
76 76
 			
77 77
 			
78 78
 			//set session config
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			set_session_config();
81 81
 			
82 82
 			//determine the current module
83
-			if(isset($this->router) && $this->router->getModule()){
83
+			if (isset($this->router) && $this->router->getModule()) {
84 84
 				$this->moduleName = $this->router->getModule();
85 85
 			}
86 86
 			//dispatch the loaded instance of super controller event
Please login to merge, or discard this patch.
core/bootstrap.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	
43 43
 	//if the application is running in CLI mode $_SESSION global variable is not available
44
-	if(IS_CLI){
44
+	if (IS_CLI) {
45 45
 		$_SESSION = array();
46 46
 	}
47 47
 		
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * The Benchmark class
62 62
 	 */
63
-	$BENCHMARK =& class_loader('Benchmark');
63
+	$BENCHMARK = & class_loader('Benchmark');
64 64
 	
65 65
 	$BENCHMARK->mark('APP_EXECUTION_START');
66 66
 	
67 67
 	/**
68 68
     * instance of the Log class
69 69
     */
70
-    $LOGGER =& class_loader('Log', 'classes');
70
+    $LOGGER = & class_loader('Log', 'classes');
71 71
 
72 72
     $LOGGER->setLogger('ApplicationBootstrap');
73 73
 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	* Verification of the PHP environment: minimum and maximum version
78 78
 	*/
79
-	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
79
+	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')) {
80 80
 		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81 81
 	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
82
+	else if (version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')) {
83 83
 		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84 84
 	}
85 85
 	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	
102 102
 	//if user have some composer packages
103 103
 	$LOGGER->debug('Check for composer autoload');
104
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
104
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
105 105
 		$LOGGER->info('The composer autoload file exists include it');
106 106
 		require_once VENDOR_PATH . 'autoload.php';
107 107
 	}
108
-	else{
108
+	else {
109 109
 		$LOGGER->info('The composer autoload file does not exist skipping');
110 110
 	}
111 111
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	* Load configurations and using the 
122 122
 	* static method "init()" to initialize the Config class .
123 123
 	*/
124
-	$CONFIG =& class_loader('Config', 'classes');	
124
+	$CONFIG = & class_loader('Config', 'classes');	
125 125
 	$CONFIG->init();
126 126
 	$BENCHMARK->mark('CONFIG_INIT_END');
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	* Load modules and using the 
131 131
 	* static method "init()" to initialize the Module class.
132 132
 	*/
133
-	$MODULE =& class_loader('Module', 'classes');
133
+	$MODULE = & class_loader('Module', 'classes');
134 134
 	$MODULE->init();
135 135
 	$BENCHMARK->mark('MODULE_INIT_END');
136 136
 
@@ -149,34 +149,34 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	* Loading Security class
151 151
 	*/
152
-	$SECURITY =& class_loader('Security', 'classes');
152
+	$SECURITY = & class_loader('Security', 'classes');
153 153
 	$SECURITY->checkWhiteListIpAccess();
154 154
 	
155 155
 	/**
156 156
 	* Loading Url class
157 157
 	*/
158
-	$URL =& class_loader('Url', 'classes');
158
+	$URL = & class_loader('Url', 'classes');
159 159
 	
160
-	if(get_config('cache_enable', false)){
160
+	if (get_config('cache_enable', false)) {
161 161
 		/**
162 162
 		 * Load Cache interface file
163 163
 		 */
164 164
 		require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
165 165
 		$cacheHandler = get_config('cache_handler');
166
-		if(! $cacheHandler){
166
+		if (!$cacheHandler) {
167 167
 			show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
168 168
 		}
169 169
 		$CACHE = null;
170 170
 		//first check if the cache handler is the system driver
171
-		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
172
-			$CACHE =& class_loader($cacheHandler, 'classes/cache');
171
+		if (file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')) {
172
+			$CACHE = & class_loader($cacheHandler, 'classes/cache');
173 173
 		}
174
-		else{
174
+		else {
175 175
 			//it's not a system driver use user library
176
-			$CACHE =& class_loader($cacheHandler);
176
+			$CACHE = & class_loader($cacheHandler);
177 177
 		}
178 178
 		//check if the page already cached
179
-		if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
179
+		if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
180 180
 			$RESPONSE = & class_loader('Response', 'classes');
181 181
 			$RESPONSE->renderFinalPageFromCache($CACHE);
182 182
 		}
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	*
37 37
 	* you can place this directory outside of your web directory, for example "/home/your_app", etc.
38 38
 	*/
39
-	define('ROOT_PATH', dirname(realpath(__FILE__)) . DS .'..' . DS);
39
+	define('ROOT_PATH', dirname(realpath(__FILE__)) . DS . '..' . DS);
40 40
 	
41 41
 	
42 42
 	//tests dir path
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	* Custom application path for tests 
63 63
 	*/
64
-	define('APPS_PATH', TESTS_PATH .'hmvc' . DS);
64
+	define('APPS_PATH', TESTS_PATH . 'hmvc' . DS);
65 65
 
66 66
 	/**
67 67
 	* The path to the controller directory of your application.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	* It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, 
198 198
 	* in HMVC architecture (hierichical, controllers, models, views).
199 199
 	*/
200
-	define('MODULE_PATH', dirname(realpath(__FILE__)) . DS .'hmvc' . DS . 'modules' . DS);
200
+	define('MODULE_PATH', dirname(realpath(__FILE__)) . DS . 'hmvc' . DS . 'modules' . DS);
201 201
 
202 202
 	/**
203 203
 	* The path to the directory of sources external to your application.
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	//Fix to allow test as if application is running in CLI mode $_SESSION global variable is not available
237 237
 	$_SESSION = array();
238 238
 	
239
-	if(! isset($_SERVER['REMOTE_ADDR'])){ 
239
+	if (!isset($_SERVER['REMOTE_ADDR'])) { 
240 240
 		$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
241 241
 	}
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	require_once  'include/autoloader.php';
245 245
 	
246 246
 	//check for composer autoload file if exists include it
247
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
247
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
248 248
 		require_once VENDOR_PATH . 'autoload.php';
249 249
 		
250 250
 		//define the class alias for vstream
Please login to merge, or discard this patch.