@@ -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 | }  | 
                                                        
@@ -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 ($className::fieldExists(key($_REQUEST['data']))) { | 
                                                        
| 320 | 317 | $_REQUEST['data'] = [$_REQUEST['data']];  | 
                                                        
@@ -386,7 +383,7 @@ discard block  | 
                                                    ||
| 386 | 383 |      { | 
                                                        
| 387 | 384 | $className = static::$recordClass;  | 
                                                        
| 388 | 385 | |
| 389 | - $this->prepareResponseModeJSON(['POST','PUT','DELETE']);  | 
                                                        |
| 386 | + $this->prepareResponseModeJSON(['POST', 'PUT', 'DELETE']);  | 
                                                        |
| 390 | 387 | |
| 391 | 388 |          if ($className::fieldExists(key($_REQUEST['data']))) { | 
                                                        
| 392 | 389 | $_REQUEST['data'] = [$_REQUEST['data']];  | 
                                                        
@@ -448,7 +445,7 @@ discard block  | 
                                                    ||
| 448 | 445 | return $this->throwUnauthorizedError();  | 
                                                        
| 449 | 446 | }  | 
                                                        
| 450 | 447 | |
| 451 | -        if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { | 
                                                        |
| 448 | +        if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { | 
                                                        |
| 452 | 449 |              if ($this->responseBuilder === JsonBuilder::class) { | 
                                                        
| 453 | 450 | $_REQUEST = JSON::getRequestData();  | 
                                                        
| 454 | 451 |                  if (is_array($_REQUEST['data'])) { | 
                                                        
@@ -598,7 +595,7 @@ discard block  | 
                                                    ||
| 598 | 595 | |
| 599 | 596 | public function getTemplateName($noun)  | 
                                                        
| 600 | 597 |      { | 
                                                        
| 601 | -        return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { | 
                                                        |
| 598 | +        return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { | 
                                                        |
| 602 | 599 | return strtoupper($matches[1]);  | 
                                                        
| 603 | 600 | }, $noun);  | 
                                                        
| 604 | 601 | }  | 
                                                        
@@ -723,14 +723,14 @@ discard block  | 
                                                    ||
| 723 | 723 | |
| 724 | 724 | // create new or update existing  | 
                                                        
| 725 | 725 |              if ($this->_isPhantom) { | 
                                                        
| 726 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleError']);  | 
                                                        |
| 726 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleError']);  | 
                                                        |
| 727 | 727 | $this->_record[$this->getPrimaryKey()] = DB::insertID();  | 
                                                        
| 728 | 728 | $this->_isPhantom = false;  | 
                                                        
| 729 | 729 | $this->_isNew = true;  | 
                                                        
| 730 | 730 |              } elseif (count($set)) { | 
                                                        
| 731 | 731 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where(  | 
                                                        
| 732 | 732 |                      sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), $this->getPrimaryKeyValue()) | 
                                                        
| 733 | - ), null, [static::class,'handleError']);  | 
                                                        |
| 733 | + ), null, [static::class, 'handleError']);  | 
                                                        |
| 734 | 734 | |
| 735 | 735 | $this->_isUpdated = true;  | 
                                                        
| 736 | 736 | }  | 
                                                        
@@ -762,7 +762,7 @@ discard block  | 
                                                    ||
| 762 | 762 | $recordValues = $this->_prepareRecordValues();  | 
                                                        
| 763 | 763 | $set = static::_mapValuesToSet($recordValues);  | 
                                                        
| 764 | 764 | |
| 765 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleError']);  | 
                                                        |
| 765 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleError']);  | 
                                                        |
| 766 | 766 | }  | 
                                                        
| 767 | 767 | }  | 
                                                        
| 768 | 768 | |
@@ -777,7 +777,7 @@ discard block  | 
                                                    ||
| 777 | 777 | */  | 
                                                        
| 778 | 778 | public static function delete($id)  | 
                                                        
| 779 | 779 |      { | 
                                                        
| 780 | -        DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleError']); | 
                                                        |
| 780 | +        DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleError']); | 
                                                        |
| 781 | 781 | |
| 782 | 782 | return DB::affectedRows() > 0;  | 
                                                        
| 783 | 783 | }  | 
                                                        
@@ -830,7 +830,7 @@ discard block  | 
                                                    ||
| 830 | 830 |      { | 
                                                        
| 831 | 831 | static::init();  | 
                                                        
| 832 | 832 |          if (!static::fieldExists($field)) { | 
                                                        
| 833 | -            throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); | 
                                                        |
| 833 | +            throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); | 
                                                        |
| 834 | 834 | }  | 
                                                        
| 835 | 835 | |
| 836 | 836 | return static::$_classFields[get_called_class()][$field]['columnName'];  | 
                                                        
@@ -1235,7 +1235,7 @@ discard block  | 
                                                    ||
| 1235 | 1235 | case 'boolean':  | 
                                                        
| 1236 | 1236 |                      { | 
                                                        
| 1237 | 1237 |                          if (!isset($this->_convertedValues[$field])) { | 
                                                        
| 1238 | - $this->_convertedValues[$field] = (bool)$value;  | 
                                                        |
| 1238 | + $this->_convertedValues[$field] = (bool) $value;  | 
                                                        |
| 1239 | 1239 | }  | 
                                                        
| 1240 | 1240 | |
| 1241 | 1241 | return $this->_convertedValues[$field];  | 
                                                        
@@ -1463,7 +1463,7 @@ discard block  | 
                                                    ||
| 1463 | 1463 |              foreach ($order as $key => $value) { | 
                                                        
| 1464 | 1464 |                  if (is_string($key)) { | 
                                                        
| 1465 | 1465 | $columnName = static::_cn($key);  | 
                                                        
| 1466 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC';  | 
                                                        |
| 1466 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC';  | 
                                                        |
| 1467 | 1467 |                  } else { | 
                                                        
| 1468 | 1468 | $columnName = static::_cn($value);  | 
                                                        
| 1469 | 1469 | $direction = 'ASC';  | 
                                                        
@@ -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 | ];  |