@@ -10,6 +10,6 @@ |
||
| 10 | 10 | use \Divergence\App as App; |
| 11 | 11 | |
| 12 | 12 | return [ |
| 13 | - 'debug' => file_exists(App::$App->ApplicationPath . '/.debug'), |
|
| 14 | - 'environment' => (file_exists(App::$App->ApplicationPath . '/.dev') ? 'dev' : 'production'), |
|
| 13 | + 'debug' => file_exists(App::$App->ApplicationPath.'/.debug'), |
|
| 14 | + 'environment' => (file_exists(App::$App->ApplicationPath.'/.dev') ? 'dev' : 'production'), |
|
| 15 | 15 | ]; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param string $label |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public static function setConnection(string $label=null) |
|
| 102 | + public static function setConnection(string $label = null) |
|
| 103 | 103 | { |
| 104 | 104 | if ($label === null && static::$currentConnection === null) { |
| 105 | 105 | static::$currentConnection = static::getDefaultLabel(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @uses static::$Timezone |
| 133 | 133 | * @uses PDO |
| 134 | 134 | */ |
| 135 | - public static function getConnection($label=null) |
|
| 135 | + public static function getConnection($label = null) |
|
| 136 | 136 | { |
| 137 | 137 | if ($label === null) { |
| 138 | 138 | if (static::$currentConnection === null) { |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | if (isset($config['socket'])) { |
| 153 | 153 | // socket connection |
| 154 | - $DSN = 'mysql:unix_socket=' . $config['socket'] . ';dbname=' . $config['database']; |
|
| 154 | + $DSN = 'mysql:unix_socket='.$config['socket'].';dbname='.$config['database']; |
|
| 155 | 155 | } else { |
| 156 | 156 | // tcp connection |
| 157 | - $DSN = 'mysql:host=' . $config['host'] . ';port=' . $config['port'] .';dbname=' . $config['database']; |
|
| 157 | + $DSN = 'mysql:host='.$config['host'].';port='.$config['port'].';dbname='.$config['database']; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | try { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | if (is_string($data)) { |
| 185 | 185 | $data = static::getConnection()->quote($data); |
| 186 | - $data = substr($data, 1, strlen($data)-2); |
|
| 186 | + $data = substr($data, 1, strlen($data) - 2); |
|
| 187 | 187 | return $data; |
| 188 | 188 | } elseif (is_array($data)) { |
| 189 | 189 | foreach ($data as $key=>$string) { |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $error = static::getConnection()->errorInfo(); |
| 521 | 521 | $message = $error[2]; |
| 522 | 522 | |
| 523 | - if (App::$App->Config['environment']=='dev') { |
|
| 523 | + if (App::$App->Config['environment'] == 'dev') { |
|
| 524 | 524 | $Handler = \Divergence\App::$App->whoops->popHandler(); |
| 525 | 525 | |
| 526 | 526 | $Handler->addDataTable("Query Information", [ |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | */ |
| 562 | 562 | protected static function startQueryLog($query) |
| 563 | 563 | { |
| 564 | - if (App::$App->Config['environment']!='dev') { |
|
| 564 | + if (App::$App->Config['environment'] != 'dev') { |
|
| 565 | 565 | return false; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // check access for API response modes |
| 69 | 69 | $this->responseBuilder = JsonBuilder::class; |
| 70 | 70 | |
| 71 | - if (in_array($this->responseBuilder, [JsonBuilder::class,JsonpBuilder::class])) { |
|
| 71 | + if (in_array($this->responseBuilder, [JsonBuilder::class, JsonpBuilder::class])) { |
|
| 72 | 72 | if (!$this->checkAPIAccess()) { |
| 73 | 73 | return $this->throwAPIUnAuthorizedError(); |
| 74 | 74 | } |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | public function handleRecordsRequest($action = false): ResponseInterface |
| 82 | 82 | { |
| 83 | 83 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 84 | - case 'save': |
|
| 85 | - { |
|
| 84 | + case 'save' : { |
|
| 86 | 85 | return $this->handleMultiSaveRequest(); |
| 87 | 86 | } |
| 88 | 87 | |
@@ -223,9 +222,7 @@ discard block |
||
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 226 | - case '': |
|
| 227 | - case false: |
|
| 228 | - { |
|
| 225 | + case '' : case false : { |
|
| 229 | 226 | $className = static::$recordClass; |
| 230 | 227 | |
| 231 | 228 | return $this->respond($this->getTemplateName($className::$singularNoun), [ |
@@ -313,7 +310,7 @@ discard block |
||
| 313 | 310 | { |
| 314 | 311 | $className = static::$recordClass; |
| 315 | 312 | |
| 316 | - $this->prepareResponseModeJSON(['POST','PUT']); |
|
| 313 | + $this->prepareResponseModeJSON(['POST', 'PUT']); |
|
| 317 | 314 | |
| 318 | 315 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 319 | 316 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -385,7 +382,7 @@ discard block |
||
| 385 | 382 | { |
| 386 | 383 | $className = static::$recordClass; |
| 387 | 384 | |
| 388 | - $this->prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
| 385 | + $this->prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
| 389 | 386 | |
| 390 | 387 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 391 | 388 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -447,7 +444,7 @@ discard block |
||
| 447 | 444 | return $this->throwUnauthorizedError(); |
| 448 | 445 | } |
| 449 | 446 | |
| 450 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
| 447 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
| 451 | 448 | if ($this->responseBuilder === JsonBuilder::class) { |
| 452 | 449 | $_REQUEST = JSON::getRequestData(); |
| 453 | 450 | if (is_array($_REQUEST['data'])) { |
@@ -597,7 +594,7 @@ discard block |
||
| 597 | 594 | |
| 598 | 595 | public function getTemplateName($noun) |
| 599 | 596 | { |
| 600 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
| 597 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
| 601 | 598 | return strtoupper($matches[1]); |
| 602 | 599 | }, $noun); |
| 603 | 600 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | public function config($Label) |
| 45 | 45 | { |
| 46 | - $Config = $this->ApplicationPath . '/config/' . $Label . '.php'; |
|
| 46 | + $Config = $this->ApplicationPath.'/config/'.$Label.'.php'; |
|
| 47 | 47 | if (!file_exists($Config)) { |
| 48 | - throw new \Exception($Config . ' not found in '.static::class.'::config()'); |
|
| 48 | + throw new \Exception($Config.' not found in '.static::class.'::config()'); |
|
| 49 | 49 | } |
| 50 | 50 | return require $Config; |
| 51 | 51 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public static $searchConditions = [ |
| 82 | 82 | 'Caption' => [ |
| 83 | - 'qualifiers' => ['any','caption'], |
|
| 83 | + 'qualifiers' => ['any', 'caption'], |
|
| 84 | 84 | 'points' => 2, |
| 85 | 85 | 'sql' => 'Caption LIKE "%%%s%%"', |
| 86 | 86 | ], |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | public static $defaultFilenameFormat = 'default.%s.jpg'; |
| 110 | 110 | public static $newDirectoryPermissions = 0775; |
| 111 | 111 | public static $newFilePermissions = 0664; |
| 112 | - public static $magicPath = null;//'/usr/share/misc/magic.mgc'; |
|
| 112 | + public static $magicPath = null; //'/usr/share/misc/magic.mgc'; |
|
| 113 | 113 | public static $useFaceDetection = true; |
| 114 | 114 | public static $faceDetectionTimeLimit = 10; |
| 115 | 115 | |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | public static function getBlankPath($contextClass) |
| 630 | 630 | { |
| 631 | - $path = ['site-root','img',sprintf(static::$defaultFilenameFormat, $contextClass)]; |
|
| 631 | + $path = ['site-root', 'img', sprintf(static::$defaultFilenameFormat, $contextClass)]; |
|
| 632 | 632 | |
| 633 | 633 | if ($node = Site::resolvePath($path)) { |
| 634 | 634 | return $node->RealPath; |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | $Session->setFields($sessionData); |
| 114 | 114 | if (function_exists('fastcgi_finish_request')) { |
| 115 | 115 | // @codeCoverageIgnoreStart |
| 116 | - register_shutdown_function(function ($Session) { |
|
| 116 | + register_shutdown_function(function($Session) { |
|
| 117 | 117 | $Session->save(); |
| 118 | 118 | }, $Session); |
| 119 | 119 | // @codeCoverageIgnoreEnd |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | static::$tableName, |
| 724 | 724 | join(',', $set), |
| 725 | 725 | ], |
| 726 | - [static::class,'handleError'] |
|
| 726 | + [static::class, 'handleError'] |
|
| 727 | 727 | ); |
| 728 | 728 | $this->_record[static::$primaryKey ? static::$primaryKey : 'ID'] = DB::insertID(); |
| 729 | 729 | $this->_isPhantom = false; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), |
| 738 | 738 | $this->getPrimaryKeyValue(), |
| 739 | 739 | ], |
| 740 | - [static::class,'handleError'] |
|
| 740 | + [static::class, 'handleError'] |
|
| 741 | 741 | ); |
| 742 | 742 | |
| 743 | 743 | $this->_isUpdated = true; |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | static::$tableName, |
| 796 | 796 | static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), |
| 797 | 797 | $id, |
| 798 | - ], [static::class,'handleError']); |
|
| 798 | + ], [static::class, 'handleError']); |
|
| 799 | 799 | |
| 800 | 800 | return DB::affectedRows() > 0; |
| 801 | 801 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | return ', '.$value.' AS '.$key; |
| 815 | 815 | } |
| 816 | 816 | } else { |
| 817 | - return ', ' . $columns; |
|
| 817 | + return ', '.$columns; |
|
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | } |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | public static function buildHaving($having) |
| 829 | 829 | { |
| 830 | 830 | if (!empty($having)) { |
| 831 | - return ' HAVING (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; |
|
| 831 | + return ' HAVING ('.(is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having).')'; |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | { |
| 892 | 892 | static::init(); |
| 893 | 893 | if (!static::fieldExists($field)) { |
| 894 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
| 894 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1296,7 +1296,7 @@ discard block |
||
| 1296 | 1296 | case 'boolean': |
| 1297 | 1297 | { |
| 1298 | 1298 | if (!isset($this->_convertedValues[$field])) { |
| 1299 | - $this->_convertedValues[$field] = (boolean)$value; |
|
| 1299 | + $this->_convertedValues[$field] = (boolean) $value; |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | return $this->_convertedValues[$field]; |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | foreach ($order as $key => $value) { |
| 1525 | 1525 | if (is_string($key)) { |
| 1526 | 1526 | $columnName = static::_cn($key); |
| 1527 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
| 1527 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
| 1528 | 1528 | } else { |
| 1529 | 1529 | $columnName = static::_cn($value); |
| 1530 | 1530 | $direction = 'ASC'; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public $searchConditions = [ |
| 41 | 41 | 'Caption' => [ |
| 42 | - 'qualifiers' => ['any','caption'] |
|
| 42 | + 'qualifiers' => ['any', 'caption'] |
|
| 43 | 43 | ,'points' => 2 |
| 44 | 44 | ,'sql' => 'Caption LIKE "%%%s%%"', |
| 45 | 45 | ] |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') { |
| 192 | 192 | $put = fopen(static::$inputStream, 'r'); // open input stream |
| 193 | 193 | |
| 194 | - $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
| 194 | + $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
| 195 | 195 | $fp = fopen($tmp, 'w'); // open write stream to temp file |
| 196 | 196 | |
| 197 | 197 | // write |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | return $this->respond('uploadComplete', [ |
| 230 | - 'success' => (boolean)$Media |
|
| 230 | + 'success' => (boolean) $Media |
|
| 231 | 231 | ,'data' => $Media, |
| 232 | 232 | ]); |
| 233 | 233 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // send caching headers |
| 280 | - $expires = 60*60*24*365; |
|
| 280 | + $expires = 60 * 60 * 24 * 365; |
|
| 281 | 281 | if (!headers_sent()) { |
| 282 | 282 | // @codeCoverageIgnoreStart |
| 283 | 283 | header("Cache-Control: public, max-age=$expires"); |
| 284 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
| 284 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
| 285 | 285 | header('Pragma: public'); |
| 286 | 286 | // @codeCoverageIgnoreEnd |
| 287 | 287 | } |
@@ -524,9 +524,9 @@ discard block |
||
| 524 | 524 | // send caching headers |
| 525 | 525 | if (!headers_sent()) { |
| 526 | 526 | // @codeCoverageIgnoreStart |
| 527 | - $expires = 60*60*24*365; |
|
| 527 | + $expires = 60 * 60 * 24 * 365; |
|
| 528 | 528 | header("Cache-Control: public, max-age=$expires"); |
| 529 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
| 529 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
| 530 | 530 | header('Pragma: public'); |
| 531 | 531 | // @codeCoverageIgnoreEnd |
| 532 | 532 | } |
@@ -28,17 +28,17 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function setBooleanValue($value): bool |
| 30 | 30 | { |
| 31 | - return (boolean)$value; |
|
| 31 | + return (boolean) $value; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function setDecimalValue($value): ?float |
| 35 | 35 | { |
| 36 | - return is_null($value) ? null : (float)preg_replace('/[^-\d.]/', '', $value); |
|
| 36 | + return is_null($value) ? null : (float) preg_replace('/[^-\d.]/', '', $value); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function setIntegerValue($value): ?int |
| 40 | 40 | { |
| 41 | - return is_null($value) ? null : (int)preg_replace('/[^-\d]/', '', $value); |
|
| 41 | + return is_null($value) ? null : (int) preg_replace('/[^-\d]/', '', $value); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function setTimestampValue($value): ?string |