@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | static::$tableName, |
532 | 532 | join(',', $set), |
533 | 533 | ], |
534 | - [static::class,'handleError'] |
|
534 | + [static::class, 'handleError'] |
|
535 | 535 | ); |
536 | 536 | |
537 | 537 | $this->_record[static::$primaryKey ? static::$primaryKey : 'ID'] = DB::insertID(); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), |
547 | 547 | $this->getPrimaryKeyValue(), |
548 | 548 | ], |
549 | - [static::class,'handleError'] |
|
549 | + [static::class, 'handleError'] |
|
550 | 550 | ); |
551 | 551 | |
552 | 552 | $this->_isUpdated = true; |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | static::$tableName, |
596 | 596 | static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), |
597 | 597 | $id, |
598 | - ], [static::class,'handleError']); |
|
598 | + ], [static::class, 'handleError']); |
|
599 | 599 | |
600 | 600 | return DB::affectedRows() > 0; |
601 | 601 | } |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($cacheIndex) { |
663 | 663 | $key = sprintf('%s/%s:%s', static::$tableName, $field, $value); |
664 | - return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']); |
|
664 | + return DB::oneRecordCached($key, $query, $params, [static::class, 'handleError']); |
|
665 | 665 | } else { |
666 | - return DB::oneRecord($query, $params, [static::class,'handleError']); |
|
666 | + return DB::oneRecord($query, $params, [static::class, 'handleError']); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
@@ -697,13 +697,13 @@ discard block |
||
697 | 697 | $order ? 'ORDER BY '.join(',', $order) : '', |
698 | 698 | ], |
699 | 699 | |
700 | - [static::class,'handleError'] |
|
700 | + [static::class, 'handleError'] |
|
701 | 701 | ); |
702 | 702 | } |
703 | 703 | |
704 | 704 | public static function getByQuery($query, $params = []) |
705 | 705 | { |
706 | - return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleError'])); |
|
706 | + return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleError'])); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | public static function getAllByClass($className = false, $options = []) |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | return ', '.$value.' AS '.$key; |
751 | 751 | } |
752 | 752 | } else { |
753 | - return ', ' . $columns; |
|
753 | + return ', '.$columns; |
|
754 | 754 | } |
755 | 755 | } |
756 | 756 | } |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | public static function buildHaving($having) |
759 | 759 | { |
760 | 760 | if (!empty($having)) { |
761 | - return ' HAVING (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; |
|
761 | + return ' HAVING ('.(is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having).')'; |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | ]; |
802 | 802 | |
803 | 803 | if ($options['order']) { |
804 | - $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); |
|
804 | + $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order'])); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | if ($options['limit']) { |
@@ -809,9 +809,9 @@ discard block |
||
809 | 809 | } |
810 | 810 | |
811 | 811 | if ($options['indexField']) { |
812 | - return DB::table(static::_cn($options['indexField']), $query, $params, [static::class,'handleError']); |
|
812 | + return DB::table(static::_cn($options['indexField']), $query, $params, [static::class, 'handleError']); |
|
813 | 813 | } else { |
814 | - return DB::allRecords($query, $params, [static::class,'handleError']); |
|
814 | + return DB::allRecords($query, $params, [static::class, 'handleError']); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | ]; |
837 | 837 | |
838 | 838 | if ($options['order']) { |
839 | - $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); |
|
839 | + $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order'])); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | if ($options['limit']) { |
@@ -844,20 +844,20 @@ discard block |
||
844 | 844 | } |
845 | 845 | |
846 | 846 | if ($options['indexField']) { |
847 | - return DB::table(static::_cn($options['indexField']), $query, $params, [static::class,'handleError']); |
|
847 | + return DB::table(static::_cn($options['indexField']), $query, $params, [static::class, 'handleError']); |
|
848 | 848 | } else { |
849 | - return DB::allRecords($query, $params, [static::class,'handleError']); |
|
849 | + return DB::allRecords($query, $params, [static::class, 'handleError']); |
|
850 | 850 | } |
851 | 851 | } |
852 | 852 | |
853 | 853 | public static function getAllByQuery($query, $params = []) |
854 | 854 | { |
855 | - return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleError'])); |
|
855 | + return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleError'])); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | public static function getTableByQuery($keyField, $query, $params = []) |
859 | 859 | { |
860 | - return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleError'])); |
|
860 | + return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleError'])); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | { |
956 | 956 | static::init(); |
957 | 957 | if (!static::fieldExists($field)) { |
958 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
958 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | case 'boolean': |
1317 | 1317 | { |
1318 | 1318 | if (!isset($this->_convertedValues[$field])) { |
1319 | - $this->_convertedValues[$field] = (boolean)$value; |
|
1319 | + $this->_convertedValues[$field] = (boolean) $value; |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | return $this->_convertedValues[$field]; |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | |
1356 | 1356 | protected function _setBooleanValue($value) |
1357 | 1357 | { |
1358 | - return (boolean)$value; |
|
1358 | + return (boolean) $value; |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | protected function _setDecimalValue($value) |
@@ -1595,7 +1595,7 @@ discard block |
||
1595 | 1595 | foreach ($order as $key => $value) { |
1596 | 1596 | if (is_string($key)) { |
1597 | 1597 | $columnName = static::_cn($key); |
1598 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
1598 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
1599 | 1599 | } else { |
1600 | 1600 | $columnName = static::_cn($value); |
1601 | 1601 | $direction = 'ASC'; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if (static::peekPath() == 'json') { |
38 | 38 | // check access for API response modes |
39 | 39 | static::$responseMode = static::shiftPath(); |
40 | - if (in_array(static::$responseMode, ['json','jsonp'])) { |
|
40 | + if (in_array(static::$responseMode, ['json', 'jsonp'])) { |
|
41 | 41 | if (!static::checkAPIAccess()) { |
42 | 42 | return static::throwAPIUnAuthorizedError(); |
43 | 43 | } |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | public static function handleRecordsRequest($action = false) |
52 | 52 | { |
53 | 53 | switch ($action ? $action : $action = static::shiftPath()) { |
54 | - case 'save': |
|
55 | - { |
|
54 | + case 'save' : { |
|
56 | 55 | return static::handleMultiSaveRequest(); |
57 | 56 | } |
58 | 57 | |
@@ -190,9 +189,7 @@ discard block |
||
190 | 189 | } |
191 | 190 | |
192 | 191 | switch ($action ? $action : $action = static::shiftPath()) { |
193 | - case '': |
|
194 | - case false: |
|
195 | - { |
|
192 | + case '' : case false : { |
|
196 | 193 | $className = static::$recordClass; |
197 | 194 | |
198 | 195 | return static::respond(static::getTemplateName($className::$singularNoun), [ |
@@ -280,7 +277,7 @@ discard block |
||
280 | 277 | { |
281 | 278 | $className = static::$recordClass; |
282 | 279 | |
283 | - static::prepareResponseModeJSON(['POST','PUT']); |
|
280 | + static::prepareResponseModeJSON(['POST', 'PUT']); |
|
284 | 281 | |
285 | 282 | if ($className::fieldExists(key($_REQUEST['data']))) { |
286 | 283 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -352,7 +349,7 @@ discard block |
||
352 | 349 | { |
353 | 350 | $className = static::$recordClass; |
354 | 351 | |
355 | - static::prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
352 | + static::prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
356 | 353 | |
357 | 354 | if ($className::fieldExists(key($_REQUEST['data']))) { |
358 | 355 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -414,7 +411,7 @@ discard block |
||
414 | 411 | return static::throwUnauthorizedError(); |
415 | 412 | } |
416 | 413 | |
417 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
414 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
418 | 415 | if (static::$responseMode == 'json') { |
419 | 416 | $_REQUEST = JSON::getRequestData(); |
420 | 417 | if (is_array($_REQUEST['data'])) { |
@@ -575,7 +572,7 @@ discard block |
||
575 | 572 | |
576 | 573 | public static function getTemplateName($noun) |
577 | 574 | { |
578 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
575 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
579 | 576 | return strtoupper($matches[1]); |
580 | 577 | }, $noun); |
581 | 578 | } |