Completed
Push — master ( 6d0531...184d54 )
by Henry
02:31
created
config/app.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
 use \Divergence\App as App;
3 3
 
4 4
 return [
5
-    'debug'			=>	file_exists(App::$ApplicationPath . '/.debug'),
6
-    'environment'	=>	(file_exists(App::$ApplicationPath . '/.dev') ? 'dev' : 'production'),
5
+    'debug'			=>	file_exists(App::$ApplicationPath.'/.debug'),
6
+    'environment'	=>	(file_exists(App::$ApplicationPath.'/.dev') ? 'dev' : 'production'),
7 7
 ];
Please login to merge, or discard this patch.
src/IO/Database/SQL.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
          * Keep it. We don't need a database connection to escape strings.
34 34
          */
35 35
         return str_replace(
36
-            ["\\",  "\x00", "\n",  "\r",  "'",  '"', "\x1a"],
37
-            ["\\\\","\\0","\\n", "\\r", "\'", '\"', "\\Z"],
36
+            ["\\", "\x00", "\n", "\r", "'", '"', "\x1a"],
37
+            ["\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"],
38 38
             $str
39 39
         );
40 40
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             case 'integer':
143 143
                 return 'int'.($field['unsigned'] ? ' unsigned' : '').(!empty($field['zerofill']) ? ' zerofill' : '');
144 144
             case 'decimal':
145
-                return sprintf('decimal(%s)', $field['length']).(!empty($field['unsigned']) ? ' unsigned' : '').(!empty($field['zerofill']) ? ' zerofill' : '');;
145
+                return sprintf('decimal(%s)', $field['length']).(!empty($field['unsigned']) ? ' unsigned' : '').(!empty($field['zerofill']) ? ' zerofill' : ''); ;
146 146
             case 'float':
147 147
                 return 'float';
148 148
             case 'double':
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
                 return 'year';
173 173
 
174 174
             case 'enum':
175
-                return sprintf('enum("%s")', join('","', array_map([static::class,'escape'], $field['values'])));
175
+                return sprintf('enum("%s")', join('","', array_map([static::class, 'escape'], $field['values'])));
176 176
 
177 177
             case 'set':
178
-                return sprintf('set("%s")', join('","', array_map([static::class,'escape'], $field['values'])));
178
+                return sprintf('set("%s")', join('","', array_map([static::class, 'escape'], $field['values'])));
179 179
 
180 180
             default:
181 181
                 throw new Exception("getSQLType: unhandled type $field[type]");
Please login to merge, or discard this patch.
src/IO/Database/MySQL.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     protected static $LastStatement;
23 23
     protected static $Config;
24 24
     
25
-    public static function getConnection($label=null)
25
+    public static function getConnection($label = null)
26 26
     {
27 27
         if (!$label) {
28 28
             $label = static::getDefaultLabel();
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
             
39 39
             if ($config['socket']) {
40 40
                 // socket connection
41
-                $DSN = 'mysql:unix_socket=' . $config['socket'] . ';dbname=' . $config['database'];
41
+                $DSN = 'mysql:unix_socket='.$config['socket'].';dbname='.$config['database'];
42 42
             } else {
43 43
                 // tcp connection
44
-                $DSN = 'mysql:host=' . $config['host'] . ';port=' . $config['port'] .';dbname=' . $config['database'];
44
+                $DSN = 'mysql:host='.$config['host'].';port='.$config['port'].';dbname='.$config['database'];
45 45
             }
46 46
             
47 47
             try {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         if (is_string($data)) {
66 66
             $data = static::getConnection()->quote($data);
67
-            $data = substr($data, 1, strlen($data)-2);
67
+            $data = substr($data, 1, strlen($data) - 2);
68 68
             return $data;
69 69
         } elseif (is_array($data)) {
70 70
             foreach ($data as $key=>$string) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         $error = static::getConnection()->errorInfo();
284 284
         $message = $error[2];
285 285
         
286
-        if (App::$Config['environment']=='dev') {
286
+        if (App::$Config['environment'] == 'dev') {
287 287
             $Handler = \Divergence\App::$whoops->popHandler();
288 288
             
289 289
             $Handler->addDataTable("Query Information", [
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     
318 318
     protected static function startQueryLog($query)
319 319
     {
320
-        if (App::$Config['environment']!='dev') {
320
+        if (App::$Config['environment'] != 'dev') {
321 321
             return false;
322 322
         }
323 323
         
Please login to merge, or discard this patch.
src/Models/ActiveRecord.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@
 block discarded – undo
86 86
     
87 87
     
88 88
     /**
89
-    * Validation checks
90
-    * @var array
91
-    */
89
+     * Validation checks
90
+     * @var array
91
+     */
92 92
     public static $validators = [];
93 93
 
94 94
     /**
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                         static::$tableName,
439 439
                         join(',', $set),
440 440
                     ],
441
-                    [static::class,'handleError']
441
+                    [static::class, 'handleError']
442 442
                 );
443 443
                 
444 444
                 $this->_record[static::$primaryKey ? static::$primaryKey : 'ID'] = DB::insertID();
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
                         static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'),
454 454
                         $this->getPrimaryKeyValue(),
455 455
                     ],
456
-                    [static::class,'handleError']
456
+                    [static::class, 'handleError']
457 457
                 );
458 458
                 
459 459
                 $this->_isUpdated = true;
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             static::$tableName,
522 522
             static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'),
523 523
             $id,
524
-        ], [static::class,'handleError']);
524
+        ], [static::class, 'handleError']);
525 525
         
526 526
         return DB::affectedRows() > 0;
527 527
     }
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
     
588 588
         if ($cacheIndex) {
589 589
             $key = sprintf('%s/%s:%s', static::$tableName, $field, $value);
590
-            return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']);
590
+            return DB::oneRecordCached($key, $query, $params, [static::class, 'handleError']);
591 591
         } else {
592
-            return DB::oneRecord($query, $params, [static::class,'handleError']);
592
+            return DB::oneRecord($query, $params, [static::class, 'handleError']);
593 593
         }
594 594
     }
595 595
     
@@ -623,13 +623,13 @@  discard block
 block discarded – undo
623 623
                 $order ? 'ORDER BY '.join(',', $order) : '',
624 624
             ],
625 625
         
626
-            [static::class,'handleError']
626
+            [static::class, 'handleError']
627 627
         );
628 628
     }
629 629
     
630 630
     public static function getByQuery($query, $params = [])
631 631
     {
632
-        return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleError']));
632
+        return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleError']));
633 633
     }
634 634
 
635 635
     public static function getAllByClass($className = false, $options = [])
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
         }
725 725
         
726 726
         // build query
727
-        $query  = 'SELECT %1$s `%3$s`.*';
727
+        $query = 'SELECT %1$s `%3$s`.*';
728 728
         
729 729
         if (!empty($options['extraColumns'])) {
730 730
             if (is_array($options['extraColumns'])) {
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
                     $query .= ', '.$value.' AS '.$key;
733 733
                 }
734 734
             } else {
735
-                $query .= ', ' . $options['extraColumns'];
735
+                $query .= ', '.$options['extraColumns'];
736 736
             }
737 737
         }
738 738
         $query .= ' FROM `%2$s` AS `%3$s` %4$s';
739 739
         $query .= ' WHERE (%5$s)';
740 740
         
741 741
         if (!empty($options['having'])) {
742
-            $query .= ' HAVING (' . (is_array($options['having']) ? join(') AND (', static::_mapConditions($options['having'])) : $options['having']) . ')';
742
+            $query .= ' HAVING ('.(is_array($options['having']) ? join(') AND (', static::_mapConditions($options['having'])) : $options['having']).')';
743 743
         }
744 744
         
745 745
         $params = [
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
         
754 754
 
755 755
         if ($options['order']) {
756
-            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
756
+            $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order']));
757 757
         }
758 758
         
759 759
         if ($options['limit']) {
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
         }
762 762
         
763 763
         if ($options['indexField']) {
764
-            return DB::table(static::_cn($options['indexField']), $query, $params, [static::class,'handleError']);
764
+            return DB::table(static::_cn($options['indexField']), $query, $params, [static::class, 'handleError']);
765 765
         } else {
766
-            return DB::allRecords($query, $params, [static::class,'handleError']);
766
+            return DB::allRecords($query, $params, [static::class, 'handleError']);
767 767
         }
768 768
     }
769 769
     
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         ];
789 789
         
790 790
         if ($options['order']) {
791
-            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
791
+            $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order']));
792 792
         }
793 793
         
794 794
         if ($options['limit']) {
@@ -796,20 +796,20 @@  discard block
 block discarded – undo
796 796
         }
797 797
 
798 798
         if ($options['indexField']) {
799
-            return DB::table(static::_cn($options['indexField']), $query, $params, [static::class,'handleError']);
799
+            return DB::table(static::_cn($options['indexField']), $query, $params, [static::class, 'handleError']);
800 800
         } else {
801
-            return DB::allRecords($query, $params, [static::class,'handleError']);
801
+            return DB::allRecords($query, $params, [static::class, 'handleError']);
802 802
         }
803 803
     }
804 804
     
805 805
     public static function getAllByQuery($query, $params = [])
806 806
     {
807
-        return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleError']));
807
+        return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleError']));
808 808
     }
809 809
 
810 810
     public static function getTableByQuery($keyField, $query, $params = [])
811 811
     {
812
-        return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleError']));
812
+        return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleError']));
813 813
     }
814 814
 
815 815
     
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
     {
913 913
         static::init();
914 914
         if (!static::fieldExists($field)) {
915
-            throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field);
915
+            throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field);
916 916
         }
917 917
         
918 918
         return static::$_classFields[get_called_class()][$field]['columnName'];
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
                 case 'boolean':
1244 1244
                 {
1245 1245
                     if (!isset($this->_convertedValues[$field])) {
1246
-                        $this->_convertedValues[$field] = (boolean)$value;
1246
+                        $this->_convertedValues[$field] = (boolean) $value;
1247 1247
                     }
1248 1248
                     
1249 1249
                     return $this->_convertedValues[$field];
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
             
1325 1325
             case 'boolean':
1326 1326
             {
1327
-                $value = (boolean)$value;
1327
+                $value = (boolean) $value;
1328 1328
             }
1329 1329
             
1330 1330
             case 'decimal':
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
             foreach ($order as $key => $value) {
1520 1520
                 if (is_string($key)) {
1521 1521
                     $columnName = static::_cn($key);
1522
-                    $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC';
1522
+                    $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC';
1523 1523
                 } else {
1524 1524
                     $columnName = static::_cn($value);
1525 1525
                     $direction = 'ASC';
Please login to merge, or discard this patch.
src/Models/RecordValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
 
99 99
         // check validator
100 100
         if (!is_callable($validator)) {
101
-            throw new Exception('Validator for field ' . $options['id'] . ' is not callable');
101
+            throw new Exception('Validator for field '.$options['id'].' is not callable');
102 102
         }
103 103
 
104 104
 
Please login to merge, or discard this patch.
src/Models/Relations.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         
69 69
         if ($options['type'] == 'one-one') {
70 70
             if (empty($options['local'])) {
71
-                $options['local'] = $relationship . 'ID';
71
+                $options['local'] = $relationship.'ID';
72 72
             }
73 73
                 
74 74
             if (empty($options['foreign'])) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             }
81 81
                     
82 82
             if (empty($options['foreign'])) {
83
-                $options['foreign'] =  $classShortName. 'ID';
83
+                $options['foreign'] = $classShortName.'ID';
84 84
             }
85 85
                 
86 86
             if (!isset($options['indexField'])) {
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
             }
143 143
                 
144 144
             if (empty($options['linkLocal'])) {
145
-                $options['linkLocal'] = $classShortName . 'ID';
145
+                $options['linkLocal'] = $classShortName.'ID';
146 146
             }
147 147
         
148 148
             if (empty($options['linkForeign'])) {
149 149
                 $foreignShortname = basename(str_replace('\\', '/', $options['class']::$rootClass));
150
-                $options['linkForeign'] =  $foreignShortname . 'ID';
150
+                $options['linkForeign'] = $foreignShortname.'ID';
151 151
             }
152 152
         
153 153
             if (empty($options['local'])) {
Please login to merge, or discard this patch.
src/Models/Versioning.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
         ];
67 67
         
68 68
         if ($options['order']) {
69
-            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
69
+            $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order']));
70 70
         }
71 71
         
72 72
         if ($options['limit']) {
Please login to merge, or discard this patch.
src/Controllers/RequestHandler.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@
 block discarded – undo
31 31
         }
32 32
     
33 33
         switch ($responseMode ? $responseMode : static::$responseMode) {
34
-            case 'json':
35
-                JSON::translateAndRespond($responseData);
34
+            case 'json' : JSON::translateAndRespond($responseData);
36 35
                 break;
37 36
             case 'jsonp':
38 37
                 JSONP::translateAndRespond($responseData);
Please login to merge, or discard this patch.
src/Controllers/RecordsRequestHandler.php 1 patch
Spacing   +7 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         if (static::peekPath() == 'json') {
36 36
             // check access for API response modes
37 37
             static::$responseMode = static::shiftPath();
38
-            if (in_array(static::$responseMode, ['json','jsonp'])) {
38
+            if (in_array(static::$responseMode, ['json', 'jsonp'])) {
39 39
                 if (!static::checkAPIAccess()) {
40 40
                     return static::throwAPIUnAuthorizedError();
41 41
                 }
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
     public static function handleRecordsRequest($action = false)
50 50
     {
51 51
         switch ($action ? $action : $action = static::shiftPath()) {
52
-            case 'save':
53
-            {
52
+            case 'save' : {
54 53
                 return static::handleMultiSaveRequest();
55 54
             }
56 55
             
@@ -175,9 +174,7 @@  discard block
 block discarded – undo
175 174
     public static function handleRecordRequest(ActiveRecord $Record, $action = false)
176 175
     {
177 176
         switch ($action ? $action : $action = static::shiftPath()) {
178
-            case '':
179
-            case false:
180
-            {
177
+            case '' : case false : {
181 178
                 $className = static::$recordClass;
182 179
                 
183 180
                 return static::respond(static::getTemplateName($className::$singularNoun), [
@@ -211,7 +208,7 @@  discard block
 block discarded – undo
211 208
     
212 209
         $PrimaryKey = $className::getPrimaryKey();
213 210
             
214
-        if (static::$responseMode == 'json' && in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) {
211
+        if (static::$responseMode == 'json' && in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) {
215 212
             $JSONData = JSON::getRequestData();
216 213
             if (is_array($JSONData)) {
217 214
                 $_REQUEST = $JSONData;
@@ -299,7 +296,7 @@  discard block
 block discarded – undo
299 296
 
300 297
         $PrimaryKey = $className::getPrimaryKey();
301 298
             
302
-        if (static::$responseMode == 'json' && in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT','DELETE'])) {
299
+        if (static::$responseMode == 'json' && in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT', 'DELETE'])) {
303 300
             $JSONData = JSON::getRequestData();
304 301
             if (is_array($JSONData)) {
305 302
                 $_REQUEST = $JSONData;
@@ -394,7 +391,7 @@  discard block
 block discarded – undo
394 391
             return static::throwUnauthorizedError();
395 392
         }
396 393
 
397
-        if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) {
394
+        if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) {
398 395
             if (static::$responseMode == 'json') {
399 396
                 $_REQUEST = JSON::getRequestData();
400 397
                 if (is_array($_REQUEST['data'])) {
@@ -554,7 +551,7 @@  discard block
 block discarded – undo
554 551
 
555 552
     public static function getTemplateName($noun)
556 553
     {
557
-        return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) {
554
+        return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) {
558 555
             return strtoupper($matches[1]);
559 556
         }, $noun);
560 557
     }
Please login to merge, or discard this patch.