@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | public function __toString(): string |
53 | 53 | { |
54 | - $expression = ($this->calcFoundRows ? 'SQL_CALC_FOUND_ROWS ' : '') . $this->expression; |
|
54 | + $expression = ($this->calcFoundRows ? 'SQL_CALC_FOUND_ROWS ' : '').$this->expression; |
|
55 | 55 | |
56 | 56 | if (isset($this->tableAlias)) { |
57 | 57 | $from = sprintf('`%s` AS `%s`', $this->table, $this->tableAlias); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public $searchConditions = [ |
42 | 42 | 'Caption' => [ |
43 | - 'qualifiers' => ['any','caption'] |
|
43 | + 'qualifiers' => ['any', 'caption'] |
|
44 | 44 | ,'points' => 2 |
45 | 45 | ,'sql' => 'Caption LIKE "%%%s%%"', |
46 | 46 | ] |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') { |
193 | 193 | $put = fopen(static::$inputStream, 'r'); // open input stream |
194 | 194 | |
195 | - $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
195 | + $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
196 | 196 | $fp = fopen($tmp, 'w'); // open write stream to temp file |
197 | 197 | |
198 | 198 | // write |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | return $this->respond('uploadComplete', [ |
231 | - 'success' => (bool)$Media |
|
231 | + 'success' => (bool) $Media |
|
232 | 232 | ,'data' => $Media, |
233 | 233 | ]); |
234 | 234 | } |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | // send caching headers |
281 | - $expires = 60*60*24*365; |
|
281 | + $expires = 60 * 60 * 24 * 365; |
|
282 | 282 | if (!headers_sent()) { |
283 | 283 | // @codeCoverageIgnoreStart |
284 | 284 | header("Cache-Control: public, max-age=$expires"); |
285 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
285 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
286 | 286 | header('Pragma: public'); |
287 | 287 | // @codeCoverageIgnoreEnd |
288 | 288 | } |
@@ -525,9 +525,9 @@ discard block |
||
525 | 525 | // send caching headers |
526 | 526 | if (!headers_sent()) { |
527 | 527 | // @codeCoverageIgnoreStart |
528 | - $expires = 60*60*24*365; |
|
528 | + $expires = 60 * 60 * 24 * 365; |
|
529 | 529 | header("Cache-Control: public, max-age=$expires"); |
530 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
530 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
531 | 531 | header('Pragma: public'); |
532 | 532 | // @codeCoverageIgnoreEnd |
533 | 533 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | // extract video streams |
124 | - $videoStreams = array_filter($output['streams'], function ($streamInfo) { |
|
124 | + $videoStreams = array_filter($output['streams'], function($streamInfo) { |
|
125 | 125 | return $streamInfo['codec_type'] == 'video'; |
126 | 126 | }); |
127 | 127 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | $mediaInfo['streams'] = $output['streams']; |
134 | 134 | $mediaInfo['videoStream'] = array_shift($videoStreams); |
135 | 135 | |
136 | - $mediaInfo['width'] = (int)$mediaInfo['videoStream']['width']; |
|
137 | - $mediaInfo['height'] = (int)$mediaInfo['videoStream']['height']; |
|
138 | - $mediaInfo['duration'] = (float)$mediaInfo['videoStream']['duration']; |
|
136 | + $mediaInfo['width'] = (int) $mediaInfo['videoStream']['width']; |
|
137 | + $mediaInfo['height'] = (int) $mediaInfo['videoStream']['height']; |
|
138 | + $mediaInfo['duration'] = (float) $mediaInfo['videoStream']['duration']; |
|
139 | 139 | |
140 | 140 | return $mediaInfo; |
141 | 141 | } |
@@ -29,17 +29,17 @@ |
||
29 | 29 | |
30 | 30 | public function setBooleanValue($value): bool |
31 | 31 | { |
32 | - return (bool)$value; |
|
32 | + return (bool) $value; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setDecimalValue($value): ?float |
36 | 36 | { |
37 | - return is_null($value) ? null : (float)preg_replace('/[^-\d.]/', '', $value); |
|
37 | + return is_null($value) ? null : (float) preg_replace('/[^-\d.]/', '', $value); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setIntegerValue($value): ?int |
41 | 41 | { |
42 | - return is_null($value) ? null : (int)preg_replace('/[^-\d]/', '', $value); |
|
42 | + return is_null($value) ? null : (int) preg_replace('/[^-\d]/', '', $value); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function setTimestampValue($value): ?string |
@@ -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 | ]; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | return DB::oneRecord( |
167 | 167 | (new Select())->setTable(static::$tableName)->where(join(') AND (', $conditions))->order($order ? join(',', $order) : '')->limit('1'), |
168 | 168 | null, |
169 | - [static::class,'handleException'] |
|
169 | + [static::class, 'handleException'] |
|
170 | 170 | ); |
171 | 171 | } |
172 | 172 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function getByQuery($query, $params = []) |
181 | 181 | { |
182 | - return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleException'])); |
|
182 | + return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleException'])); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | $select->limit(sprintf('%u,%u', $options['offset'], $options['limit'])); |
286 | 286 | } |
287 | 287 | if ($options['indexField']) { |
288 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
288 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
289 | 289 | } else { |
290 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
290 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public static function getAllByQuery($query, $params = []) |
302 | 302 | { |
303 | - return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleException'])); |
|
303 | + return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleException'])); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | public static function getTableByQuery($keyField, $query, $params = []) |
307 | 307 | { |
308 | - return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleException'])); |
|
308 | + return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleException'])); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | if ($options['indexField']) { |
366 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
366 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
367 | 367 | } else { |
368 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
368 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | return ', '.$value.' AS '.$key; |
436 | 436 | } |
437 | 437 | } else { |
438 | - return ', ' . $columns; |
|
438 | + return ', '.$columns; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | public static function buildHaving($having) |
450 | 450 | { |
451 | 451 | if (!empty($having)) { |
452 | - return ' (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; |
|
452 | + return ' ('.(is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having).')'; |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $label |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public static function setConnection(string $label=null) |
|
103 | + public static function setConnection(string $label = null) |
|
104 | 104 | { |
105 | 105 | if ($label === null && static::$currentConnection === null) { |
106 | 106 | static::$currentConnection = static::getDefaultLabel(); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @uses static::$Timezone |
134 | 134 | * @uses PDO |
135 | 135 | */ |
136 | - public static function getConnection($label=null) |
|
136 | + public static function getConnection($label = null) |
|
137 | 137 | { |
138 | 138 | if ($label === null) { |
139 | 139 | if (static::$currentConnection === null) { |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | |
153 | 153 | if (isset($config['socket'])) { |
154 | 154 | // socket connection |
155 | - $DSN = 'mysql:unix_socket=' . $config['socket'] . ';dbname=' . $config['database']; |
|
155 | + $DSN = 'mysql:unix_socket='.$config['socket'].';dbname='.$config['database']; |
|
156 | 156 | } else { |
157 | 157 | // tcp connection |
158 | - $DSN = 'mysql:host=' . $config['host'] . ';port=' . $config['port'] .';dbname=' . $config['database']; |
|
158 | + $DSN = 'mysql:host='.$config['host'].';port='.$config['port'].';dbname='.$config['database']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | try { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | if (is_string($data)) { |
188 | 188 | $data = static::getConnection()->quote($data); |
189 | - $data = substr($data, 1, strlen($data)-2); |
|
189 | + $data = substr($data, 1, strlen($data) - 2); |
|
190 | 190 | return $data; |
191 | 191 | } elseif (is_array($data)) { |
192 | 192 | foreach ($data as $key=>$string) { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | // execute query |
267 | 267 | try { |
268 | 268 | static::$LastStatement = static::getConnection()->query($query); |
269 | - } catch(\Exception $e) { |
|
269 | + } catch (\Exception $e) { |
|
270 | 270 | $ErrorInfo = $e->errorInfo; |
271 | 271 | if ($ErrorInfo[0] != '00000') { |
272 | 272 | static::handleException($e, $query, $queryLog, $errorHandler); |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | static::finishQueryLog($queryLog); |
301 | 301 | |
302 | 302 | return $Statement; |
303 | - } catch(\Exception $e) { |
|
303 | + } catch (\Exception $e) { |
|
304 | 304 | $ErrorInfo = $e->errorInfo; |
305 | 305 | if ($ErrorInfo[0] != '00000') { |
306 | 306 | // handledException should return a PDOStatement from a successful query so let's pass this up |
307 | 307 | $handledException = static::handleException($e, $query, $queryLog, $errorHandler); |
308 | - if (is_a($handledException,\PDOStatement::class)) { |
|
308 | + if (is_a($handledException, \PDOStatement::class)) { |
|
309 | 309 | static::$LastStatement = $handledException; |
310 | 310 | // start query log |
311 | 311 | $queryLog = static::startQueryLog($query); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $error = static::getConnection()->errorInfo(); |
513 | 513 | $message = $error[2]; |
514 | 514 | |
515 | - if (App::$App->Config['environment']=='dev') { |
|
515 | + if (App::$App->Config['environment'] == 'dev') { |
|
516 | 516 | $Handler = \Divergence\App::$App->whoops->popHandler(); |
517 | 517 | |
518 | 518 | $Handler->addDataTable("Query Information", [ |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | protected static function startQueryLog($query) |
555 | 555 | { |
556 | - if (App::$App->Config['environment']!='dev') { |
|
556 | + if (App::$App->Config['environment'] != 'dev') { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | // check access for API response modes |
70 | 70 | $this->responseBuilder = JsonBuilder::class; |
71 | 71 | |
72 | - if (in_array($this->responseBuilder, [JsonBuilder::class,JsonpBuilder::class])) { |
|
72 | + if (in_array($this->responseBuilder, [JsonBuilder::class, JsonpBuilder::class])) { |
|
73 | 73 | if (!$this->checkAPIAccess()) { |
74 | 74 | return $this->throwAPIUnAuthorizedError(); |
75 | 75 | } |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | public function handleRecordsRequest($action = false): ResponseInterface |
83 | 83 | { |
84 | 84 | switch ($action ? $action : $action = $this->shiftPath()) { |
85 | - case 'save': |
|
86 | - { |
|
85 | + case 'save' : { |
|
87 | 86 | return $this->handleMultiSaveRequest(); |
88 | 87 | } |
89 | 88 | |
@@ -224,9 +223,7 @@ discard block |
||
224 | 223 | } |
225 | 224 | |
226 | 225 | switch ($action ? $action : $action = $this->shiftPath()) { |
227 | - case '': |
|
228 | - case false: |
|
229 | - { |
|
226 | + case '' : case false : { |
|
230 | 227 | $className = static::$recordClass; |
231 | 228 | |
232 | 229 | return $this->respond($this->getTemplateName($className::$singularNoun), [ |
@@ -314,7 +311,7 @@ discard block |
||
314 | 311 | { |
315 | 312 | $className = static::$recordClass; |
316 | 313 | |
317 | - $this->prepareResponseModeJSON(['POST','PUT']); |
|
314 | + $this->prepareResponseModeJSON(['POST', 'PUT']); |
|
318 | 315 | |
319 | 316 | if (!empty($_REQUEST['data'])) { |
320 | 317 | if ($className::fieldExists(key($_REQUEST['data']))) { |
@@ -389,7 +386,7 @@ discard block |
||
389 | 386 | { |
390 | 387 | $className = static::$recordClass; |
391 | 388 | |
392 | - $this->prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
389 | + $this->prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
393 | 390 | |
394 | 391 | if (!empty($_REQUEST['data'])) { |
395 | 392 | if ($className::fieldExists(key($_REQUEST['data']))) { |
@@ -453,7 +450,7 @@ discard block |
||
453 | 450 | return $this->throwUnauthorizedError(); |
454 | 451 | } |
455 | 452 | |
456 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
453 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
457 | 454 | if ($this->responseBuilder === JsonBuilder::class) { |
458 | 455 | $_REQUEST = JSON::getRequestData(); |
459 | 456 | if (is_array($_REQUEST['data'])) { |
@@ -603,7 +600,7 @@ discard block |
||
603 | 600 | |
604 | 601 | public function getTemplateName($noun) |
605 | 602 | { |
606 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
603 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
607 | 604 | return strtoupper($matches[1]); |
608 | 605 | }, $noun); |
609 | 606 | } |