@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -24,22 +24,22 @@ |
||
24 | 24 | { |
25 | 25 | public function setStringValue($value): ?string |
26 | 26 | { |
27 | - return mb_convert_encoding($value??'', DB::$encoding, 'auto'); // normalize encoding to ASCII |
|
27 | + return mb_convert_encoding($value ?? '', DB::$encoding, 'auto'); // normalize encoding to ASCII |
|
28 | 28 | } |
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 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->ApplicationPath = $Path; |
37 | 37 | |
38 | - if (php_sapi_name()!=='cli') { |
|
38 | + if (php_sapi_name() !== 'cli') { |
|
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,8 +93,8 @@ discard block |
||
93 | 93 | |
94 | 94 | |
95 | 95 | /** |
96 | - * @var array $validators Validation checks |
|
97 | - */ |
|
96 | + * @var array $validators Validation checks |
|
97 | + */ |
|
98 | 98 | public static $validators = []; |
99 | 99 | |
100 | 100 | /** |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | } |
1135 | 1135 | } |
1136 | 1136 | } |
1137 | - } |
|
1137 | + } |
|
1138 | 1138 | } |
1139 | 1139 | return [ |
1140 | 1140 | 'fields' => $fields, |
@@ -727,11 +727,11 @@ discard block |
||
727 | 727 | |
728 | 728 | // create new or update existing |
729 | 729 | if ($this->_isPhantom) { |
730 | - DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class,'handleException']); |
|
730 | + DB::nonQuery((new Insert())->setTable(static::$tableName)->set($set), null, [static::class, 'handleException']); |
|
731 | 731 | $primaryKey = $this->getPrimaryKey(); |
732 | 732 | $insertID = DB::insertID(); |
733 | 733 | $fields = static::getClassFields(); |
734 | - if ( ($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
734 | + if (($fields[$primaryKey]['type'] ?? false) === 'integer') { |
|
735 | 735 | $insertID = intval($insertID); |
736 | 736 | } |
737 | 737 | $this->_record[$primaryKey] = $insertID; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | } elseif (count($set)) { |
742 | 742 | DB::nonQuery((new Update())->setTable(static::$tableName)->set($set)->where( |
743 | 743 | sprintf('`%s` = %u', static::_cn($this->getPrimaryKey()), $this->getPrimaryKeyValue()) |
744 | - ), null, [static::class,'handleException']); |
|
744 | + ), null, [static::class, 'handleException']); |
|
745 | 745 | |
746 | 746 | $this->_isUpdated = true; |
747 | 747 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $recordValues = $this->_prepareRecordValues(); |
774 | 774 | $set = static::_mapValuesToSet($recordValues); |
775 | 775 | |
776 | - DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class,'handleException']); |
|
776 | + DB::nonQuery((new Insert())->setTable(static::getHistoryTable())->set($set), null, [static::class, 'handleException']); |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | */ |
789 | 789 | public static function delete($id): bool |
790 | 790 | { |
791 | - DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class,'handleException']); |
|
791 | + DB::nonQuery((new Delete())->setTable(static::$tableName)->where(sprintf('`%s` = %u', static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id)), null, [static::class, 'handleException']); |
|
792 | 792 | |
793 | 793 | return DB::affectedRows() > 0; |
794 | 794 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | { |
842 | 842 | static::init(); |
843 | 843 | if (!static::fieldExists($field)) { |
844 | - throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field); |
|
844 | + throw new Exception('getColumnName called on nonexisting column: '.get_called_class().'->'.$field); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | return static::$_classFields[get_called_class()][$field]['columnName']; |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | // clear buffer (required for the next query to work without running fetchAll first |
1009 | 1009 | $Statement->closeCursor(); |
1010 | 1010 | |
1011 | - return $Connection->query((string)$query); // now the query should finish with no error |
|
1011 | + return $Connection->query((string) $query); // now the query should finish with no error |
|
1012 | 1012 | } else { |
1013 | 1013 | return DB::handleException($e, $query, $queryLog); |
1014 | 1014 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | } |
1083 | 1083 | $attributeFields = $class::_definedAttributeFields(); |
1084 | 1084 | if (!empty($attributeFields['fields'])) { |
1085 | - static::$_classFields[$className] = array_merge(static::$_classFields[$className],$attributeFields['fields']); |
|
1085 | + static::$_classFields[$className] = array_merge(static::$_classFields[$className], $attributeFields['fields']); |
|
1086 | 1086 | } |
1087 | 1087 | if (!empty($attributeFields['relations'])) { |
1088 | 1088 | $class::$relationships = $attributeFields['relations']; |
@@ -1101,14 +1101,14 @@ discard block |
||
1101 | 1101 | $fields = []; |
1102 | 1102 | $relations = []; |
1103 | 1103 | $properties = (new ReflectionClass(static::class))->getProperties(); |
1104 | - if(!empty($properties)) { |
|
1104 | + if (!empty($properties)) { |
|
1105 | 1105 | foreach ($properties as $property) { |
1106 | 1106 | if ($property->isProtected()) { |
1107 | 1107 | |
1108 | 1108 | // skip these because they are built in |
1109 | - if (in_array($property->getName(),[ |
|
1110 | - '_classFields','_classRelationships','_classBeforeSave','_classAfterSave','_fieldsDefined','_relationshipsDefined','_eventsDefined','_record','_validator' |
|
1111 | - ,'_validationErrors','_isDirty','_isValid','fieldSetMapper','_convertedValues','_originalValues','_isPhantom','_wasPhantom','_isNew','_isUpdated','_relatedObjects' |
|
1109 | + if (in_array($property->getName(), [ |
|
1110 | + '_classFields', '_classRelationships', '_classBeforeSave', '_classAfterSave', '_fieldsDefined', '_relationshipsDefined', '_eventsDefined', '_record', '_validator' |
|
1111 | + ,'_validationErrors', '_isDirty', '_isValid', 'fieldSetMapper', '_convertedValues', '_originalValues', '_isPhantom', '_wasPhantom', '_isNew', '_isUpdated', '_relatedObjects' |
|
1112 | 1112 | ])) { |
1113 | 1113 | continue; |
1114 | 1114 | } |
@@ -1116,10 +1116,10 @@ discard block |
||
1116 | 1116 | $isRelationship = false; |
1117 | 1117 | |
1118 | 1118 | if ($attributes = $property->getAttributes()) { |
1119 | - foreach($attributes as $attribute) { |
|
1119 | + foreach ($attributes as $attribute) { |
|
1120 | 1120 | $attributeName = $attribute->getName(); |
1121 | 1121 | if ($attributeName === Column::class) { |
1122 | - $fields[$property->getName()] = array_merge($attribute->getArguments(),['attributeField'=>true]); |
|
1122 | + $fields[$property->getName()] = array_merge($attribute->getArguments(), ['attributeField'=>true]); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | if ($attributeName === Relation::class) { |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | case 'boolean': |
1303 | 1303 | { |
1304 | 1304 | if (!isset($this->_convertedValues[$field])) { |
1305 | - $this->_convertedValues[$field] = (bool)$value; |
|
1305 | + $this->_convertedValues[$field] = (bool) $value; |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | return $this->_convertedValues[$field]; |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | foreach ($order as $key => $value) { |
1539 | 1539 | if (is_string($key)) { |
1540 | 1540 | $columnName = static::_cn($key); |
1541 | - $direction = strtoupper($value)=='DESC' ? 'DESC' : 'ASC'; |
|
1541 | + $direction = strtoupper($value) == 'DESC' ? 'DESC' : 'ASC'; |
|
1542 | 1542 | } else { |
1543 | 1543 | $columnName = static::_cn($value); |
1544 | 1544 | $direction = 'ASC'; |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | #[Column(notnull: false, default:null)] |
50 | 50 | protected $ContextClass; |
51 | 51 | |
52 | - #[Column(type:'int',notnull: false, default:null)] |
|
52 | + #[Column(type:'int', notnull: false, default:null)] |
|
53 | 53 | protected $ContextID; |
54 | 54 | |
55 | - #[Column(unique:true,length:32)] |
|
55 | + #[Column(unique:true, length:32)] |
|
56 | 56 | protected $Handle; |
57 | 57 | |
58 | - #[Column(type:'timestamp',notnull:false)] |
|
58 | + #[Column(type:'timestamp', notnull:false)] |
|
59 | 59 | protected $LastRequest; |
60 | 60 | |
61 | - #[Column(type:'binary',length:16)] |
|
61 | + #[Column(type:'binary', length:16)] |
|
62 | 62 | protected $LastIP; |
63 | 63 | |
64 | 64 | /** |
@@ -113,7 +113,7 @@ discard block |
||
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 |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | // set handle |
151 | 151 | if (!$this->__get('Handle')) { |
152 | - $this->__set('Handle',static::generateUniqueHandle()); |
|
152 | + $this->__set('Handle', static::generateUniqueHandle()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // call parent |