@@ -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 |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | $PreviewMedia = Media::createFromFile($previewPath, [ |
| 88 | 88 | 'ContextClass' => 'Media' |
| 89 | 89 | ,'ContextID' => $this->getValue('ID') |
| 90 | - ,'Caption' => sprintf('%u sec preview (%us-%us)', static::$previewDuration, $startTime, $startTime+static::$previewDuration), |
|
| 90 | + ,'Caption' => sprintf('%u sec preview (%us-%us)', static::$previewDuration, $startTime, $startTime + static::$previewDuration), |
|
| 91 | 91 | ]); |
| 92 | 92 | |
| 93 | 93 | return $PreviewMedia; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | return DB::oneRecord( |
| 186 | 186 | (new Select())->setTable(static::$tableName)->where(join(') AND (', $conditions))->order($order ? join(',', $order) : '')->limit('1'), |
| 187 | 187 | null, |
| 188 | - [static::class,'handleException'] |
|
| 188 | + [static::class, 'handleException'] |
|
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public static function getByQuery($query, $params = []) |
| 200 | 200 | { |
| 201 | - return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleException'])); |
|
| 201 | + return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleException'])); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | $select->limit(sprintf('%u,%u', $options['offset'], $options['limit'])); |
| 310 | 310 | } |
| 311 | 311 | if ($options['indexField']) { |
| 312 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
| 312 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
| 313 | 313 | } else { |
| 314 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
| 314 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public static function getAllByQuery($query, $params = []) |
| 326 | 326 | { |
| 327 | - return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleException'])); |
|
| 327 | + return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleException'])); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public static function getTableByQuery($keyField, $query, $params = []) |
| 339 | 339 | { |
| 340 | - return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleException'])); |
|
| 340 | + return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleException'])); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | if ($options['indexField']) { |
| 398 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
| 398 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
| 399 | 399 | } else { |
| 400 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
| 400 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | return ', '.$value.' AS '.$key; |
| 468 | 468 | } |
| 469 | 469 | } else { |
| 470 | - return ', ' . $columns; |
|
| 470 | + return ', '.$columns; |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | public static function buildHaving($having) |
| 482 | 482 | { |
| 483 | 483 | if (!empty($having)) { |
| 484 | - return ' (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; |
|
| 484 | + return ' ('.(is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having).')'; |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |
@@ -64,11 +64,11 @@ |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * Same as getByContextObject but this method lets you specify the ContextClass manually. |
|
| 68 | - * |
|
| 69 | - * @param array $record An array of database rows. |
|
| 70 | - * @return static|null An array of instantiated ActiveRecord models from the provided data. |
|
| 71 | - */ |
|
| 67 | + * Same as getByContextObject but this method lets you specify the ContextClass manually. |
|
| 68 | + * |
|
| 69 | + * @param array $record An array of database rows. |
|
| 70 | + * @return static|null An array of instantiated ActiveRecord models from the provided data. |
|
| 71 | + */ |
|
| 72 | 72 | public static function getByContext($contextClass, $contextID, $options = []) |
| 73 | 73 | { |
| 74 | 74 | if (!static::fieldExists('ContextClass')) { |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | // create new or update existing |
| 740 | 740 | if ($this->_isPhantom) { |
| 741 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleException']); |
|
| 741 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleException']); |
|
| 742 | 742 | $primaryKey = $this->getPrimaryKey(); |
| 743 | 743 | $insertID = DB::insertID(); |
| 744 | 744 | $fields = static::getClassFields(); |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | $this->_isNew = true; |
| 752 | 752 | } elseif (count($set)) { |
| 753 | 753 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where( |
| 754 | - sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), (string)$this->getPrimaryKeyValue()) |
|
| 755 | - ), null, [static::class,'handleException']); |
|
| 754 | + sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), (string) $this->getPrimaryKeyValue()) |
|
| 755 | + ), null, [static::class, 'handleException']); |
|
| 756 | 756 | |
| 757 | 757 | $this->_isUpdated = true; |
| 758 | 758 | } |
@@ -784,11 +784,11 @@ discard block |
||
| 784 | 784 | $recordValues = $this->_prepareRecordValues(); |
| 785 | 785 | $set = static::_mapValuesToSet($recordValues); |
| 786 | 786 | |
| 787 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleException']); |
|
| 787 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleException']); |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - return static::delete((string)$this->getPrimaryKeyValue()); |
|
| 791 | + return static::delete((string) $this->getPrimaryKeyValue()); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | /** |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | */ |
| 800 | 800 | public static function delete($id): bool |
| 801 | 801 | { |
| 802 | - DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleException']); |
|
| 802 | + DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleException']); |
|
| 803 | 803 | |
| 804 | 804 | return DB::affectedRows() > 0; |
| 805 | 805 | } |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | { |
| 853 | 853 | static::init(); |
| 854 | 854 | if (!static::fieldExists($field)) { |
| 855 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
| 855 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | // clear buffer (required for the next query to work without running fetchAll first |
| 1020 | 1020 | $Statement->closeCursor(); |
| 1021 | 1021 | |
| 1022 | - return $Connection->query((string)$query); // now the query should finish with no error |
|
| 1022 | + return $Connection->query((string) $query); // now the query should finish with no error |
|
| 1023 | 1023 | } else { |
| 1024 | 1024 | return DB::handleException($e, $query, $queryLog); |
| 1025 | 1025 | } |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | |
| 1119 | 1119 | // skip these because they are built in |
| 1120 | 1120 | if (in_array($property->getName(), [ |
| 1121 | - '_classFields','_classRelationships','_classBeforeSave','_classAfterSave','_fieldsDefined','_relationshipsDefined','_eventsDefined','_record','_validator' |
|
| 1122 | - ,'_validationErrors','_isDirty','_isValid','fieldSetMapper','_convertedValues','_originalValues','_isPhantom','_wasPhantom','_isNew','_isUpdated','_relatedObjects' |
|
| 1121 | + '_classFields', '_classRelationships', '_classBeforeSave', '_classAfterSave', '_fieldsDefined', '_relationshipsDefined', '_eventsDefined', '_record', '_validator' |
|
| 1122 | + ,'_validationErrors', '_isDirty', '_isValid', 'fieldSetMapper', '_convertedValues', '_originalValues', '_isPhantom', '_wasPhantom', '_isNew', '_isUpdated', '_relatedObjects' |
|
| 1123 | 1123 | ])) { |
| 1124 | 1124 | continue; |
| 1125 | 1125 | } |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | case 'boolean': |
| 1314 | 1314 | { |
| 1315 | 1315 | if (!isset($this->_convertedValues[$field])) { |
| 1316 | - $this->_convertedValues[$field] = (bool)$value; |
|
| 1316 | + $this->_convertedValues[$field] = (bool) $value; |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | return $this->_convertedValues[$field]; |
@@ -1549,7 +1549,7 @@ discard block |
||
| 1549 | 1549 | foreach ($order as $key => $value) { |
| 1550 | 1550 | if (is_string($key)) { |
| 1551 | 1551 | $columnName = static::_cn($key); |
| 1552 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
| 1552 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
| 1553 | 1553 | } else { |
| 1554 | 1554 | $columnName = static::_cn($value); |
| 1555 | 1555 | $direction = 'ASC'; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public function emit(): void |
| 51 | 51 | { |
| 52 | 52 | if (!isset($this->responseChunkSize)) { |
| 53 | - $this->responseChunkSize= 4096; |
|
| 53 | + $this->responseChunkSize = 4096; |
|
| 54 | 54 | } |
| 55 | 55 | $response = $this->response; |
| 56 | 56 | $isEmpty = $this->isResponseEmpty($response); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $this->ApplicationPath = $Path; |
| 37 | 37 | |
| 38 | - if (php_sapi_name()!=='cli' || defined('PHPUNIT_TESTSUITE')) { |
|
| 38 | + if (php_sapi_name() !== 'cli' || defined('PHPUNIT_TESTSUITE')) { |
|
| 39 | 39 | $this->Path = new Path($_SERVER['REQUEST_URI']); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function config($Label) |
| 48 | 48 | { |
| 49 | - $Config = $this->ApplicationPath . '/config/' . $Label . '.php'; |
|
| 49 | + $Config = $this->ApplicationPath.'/config/'.$Label.'.php'; |
|
| 50 | 50 | if (!file_exists($Config)) { |
| 51 | - throw new \Exception($Config . ' not found in '.static::class.'::config()'); |
|
| 51 | + throw new \Exception($Config.' not found in '.static::class.'::config()'); |
|
| 52 | 52 | } |
| 53 | 53 | return require $Config; |
| 54 | 54 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | // public methods |
| 96 | - public function getImage($sourceFile = null): false|\GdImage |
|
| 96 | + public function getImage($sourceFile = null): false | \GdImage |
|
| 97 | 97 | { |
| 98 | 98 | if (!isset($sourceFile)) { |
| 99 | 99 | $sourceFile = $this->getValue('FilesystemPath') ? $this->getValue('FilesystemPath') : $this->getValue('BlankPath'); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // extract video streams |
| 130 | - $videoStreams = array_filter($json['streams'], function ($streamInfo) { |
|
| 130 | + $videoStreams = array_filter($json['streams'], function($streamInfo) { |
|
| 131 | 131 | return $streamInfo['codec_type'] == 'video'; |
| 132 | 132 | }); |
| 133 | 133 | |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | $mediaInfo['streams'] = $json['streams']; |
| 140 | 140 | $mediaInfo['videoStream'] = array_shift($videoStreams); |
| 141 | 141 | |
| 142 | - $mediaInfo['width'] = (int)$mediaInfo['videoStream']['width']; |
|
| 143 | - $mediaInfo['height'] = (int)$mediaInfo['videoStream']['height']; |
|
| 144 | - $mediaInfo['duration'] = (float)$mediaInfo['videoStream']['duration']; |
|
| 142 | + $mediaInfo['width'] = (int) $mediaInfo['videoStream']['width']; |
|
| 143 | + $mediaInfo['height'] = (int) $mediaInfo['videoStream']['height']; |
|
| 144 | + $mediaInfo['duration'] = (float) $mediaInfo['videoStream']['duration']; |
|
| 145 | 145 | |
| 146 | 146 | return $mediaInfo; |
| 147 | 147 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | // public methods |
| 56 | - public function getImage($sourceFile = null): false|\GdImage |
|
| 56 | + public function getImage($sourceFile = null): false | \GdImage |
|
| 57 | 57 | { |
| 58 | 58 | if (!isset($sourceFile)) { |
| 59 | 59 | $sourceFile = $this->FilesystemPath ? $this->FilesystemPath : $this->BlankPath; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public static $searchConditions = [ |
| 86 | 86 | 'Caption' => [ |
| 87 | - 'qualifiers' => ['any','caption'], |
|
| 87 | + 'qualifiers' => ['any', 'caption'], |
|
| 88 | 88 | 'points' => 2, |
| 89 | 89 | 'sql' => 'Caption LIKE "%%%s%%"', |
| 90 | 90 | ], |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public static $defaultFilenameFormat = 'default.%s.jpg'; |
| 114 | 114 | public static $newDirectoryPermissions = 0775; |
| 115 | 115 | public static $newFilePermissions = 0664; |
| 116 | - public static $magicPath = null;//'/usr/share/misc/magic.mgc'; |
|
| 116 | + public static $magicPath = null; //'/usr/share/misc/magic.mgc'; |
|
| 117 | 117 | public static $useFaceDetection = true; |
| 118 | 118 | public static $faceDetectionTimeLimit = 10; |
| 119 | 119 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @throws Exception |
| 212 | 212 | * @return \GdImage|false |
| 213 | 213 | */ |
| 214 | - public function getImage($sourceFile = null): \GdImage|false |
|
| 214 | + public function getImage($sourceFile = null): \GdImage | false |
|
| 215 | 215 | { |
| 216 | 216 | if (!isset($sourceFile)) { |
| 217 | 217 | $sourceFile = $this->getValue('FilesystemPath') ? $this->getValue('FilesystemPath') : $this->getValue('BlankPath'); |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | // determine handler |
| 552 | 552 | $staticClass = get_called_class(); |
| 553 | 553 | if (!isset(static::$mimeHandlers[$mediaInfo['mimeType']]) || $staticClass != __CLASS__) { |
| 554 | - throw new Exception('No class registered for mime type "' . $mediaInfo['mimeType'] . '"'); |
|
| 554 | + throw new Exception('No class registered for mime type "'.$mediaInfo['mimeType'].'"'); |
|
| 555 | 555 | } else { |
| 556 | 556 | $className = $mediaInfo['className'] = static::$mimeHandlers[$mediaInfo['mimeType']]; |
| 557 | 557 | |