@@ -122,15 +122,15 @@ |
||
| 122 | 122 | |
| 123 | 123 | foreach ($output->streams as $stream) { |
| 124 | 124 | if (isset($stream->width)) { |
| 125 | - $meta['width'] = (int)$stream->width; |
|
| 125 | + $meta['width'] = (int) $stream->width; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | if (isset($stream->height)) { |
| 129 | - $meta['height'] = (int)$stream->height; |
|
| 129 | + $meta['height'] = (int) $stream->height; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | if (isset($stream->duration)) { |
| 133 | - $meta['duration'] = (int)$stream->duration; |
|
| 133 | + $meta['duration'] = (int) $stream->duration; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | if (isset($stream->tags->rotate)) { |
@@ -141,13 +141,11 @@ discard block |
||
| 141 | 141 | if ($rotate == 90 or $rotate == 270) { |
| 142 | 142 | list($meta['height'], $meta['width']) = array($meta['width'], $meta['height']); |
| 143 | 143 | } |
| 144 | - } |
|
| 145 | - else { |
|
| 144 | + } else { |
|
| 146 | 145 | $process->addErrorOutput('ffprobe output is null'); |
| 147 | 146 | throw new Exception($process->getErrorOutput()); |
| 148 | 147 | } |
| 149 | - } |
|
| 150 | - else { |
|
| 148 | + } else { |
|
| 151 | 149 | throw new Exception($process->getErrorOutput()); |
| 152 | 150 | } |
| 153 | 151 | |
@@ -186,12 +184,10 @@ discard block |
||
| 186 | 184 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
| 187 | 185 | if ($width and $height) { |
| 188 | 186 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$width:$height"); |
| 189 | - } |
|
| 190 | - else { |
|
| 187 | + } else { |
|
| 191 | 188 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$scale:$scale"); |
| 192 | 189 | } |
| 193 | - } |
|
| 194 | - else { |
|
| 190 | + } else { |
|
| 195 | 191 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType"); |
| 196 | 192 | } |
| 197 | 193 | |
@@ -217,12 +213,10 @@ discard block |
||
| 217 | 213 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
| 218 | 214 | if ($scale) { |
| 219 | 215 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf scale=$scale,crop=$width:$height,setsar=1"); |
| 220 | - } |
|
| 221 | - else { |
|
| 216 | + } else { |
|
| 222 | 217 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf crop=$width:$height,setsar=1"); |
| 223 | 218 | } |
| 224 | - } |
|
| 225 | - else { |
|
| 219 | + } else { |
|
| 226 | 220 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf scale=$scale,setsar=1"); |
| 227 | 221 | } |
| 228 | 222 | |
@@ -316,8 +310,7 @@ discard block |
||
| 316 | 310 | } |
| 317 | 311 | |
| 318 | 312 | $scale = "$scale:-2"; |
| 319 | - } |
|
| 320 | - else { |
|
| 313 | + } else { |
|
| 321 | 314 | $scale = ceil(($meta['height'] * $width) / $meta['width']); |
| 322 | 315 | |
| 323 | 316 | if ($scale < $height) { |
@@ -326,12 +319,10 @@ discard block |
||
| 326 | 319 | |
| 327 | 320 | $scale = "-2:$scale"; |
| 328 | 321 | } |
| 329 | - } |
|
| 330 | - else { |
|
| 322 | + } else { |
|
| 331 | 323 | $scale = ''; |
| 332 | 324 | } |
| 333 | - } |
|
| 334 | - else { |
|
| 325 | + } else { |
|
| 335 | 326 | $scale = $width ? "$width:-2" : ($height ? "-2:$height" : (self::DEFAULT_SCALE . ':-2')); |
| 336 | 327 | } |
| 337 | 328 | |
@@ -364,8 +355,7 @@ discard block |
||
| 364 | 355 | } |
| 365 | 356 | |
| 366 | 357 | throw new Exception($process->getErrorOutput()); |
| 367 | - } |
|
| 368 | - else { |
|
| 358 | + } else { |
|
| 369 | 359 | list($path, $name) = $this->splitPath($saveTo); |
| 370 | 360 | |
| 371 | 361 | $tempDir = $this->tempDir(); |
@@ -414,8 +404,7 @@ discard block |
||
| 414 | 404 | } |
| 415 | 405 | |
| 416 | 406 | throw new Exception($process->getErrorOutput()); |
| 417 | - } |
|
| 418 | - else { |
|
| 407 | + } else { |
|
| 419 | 408 | $name = basename($streamPath); |
| 420 | 409 | $temp = $name . '-' . time(); |
| 421 | 410 | |
@@ -92,8 +92,8 @@ |
||
| 92 | 92 | $size = $this->image->getSize(); |
| 93 | 93 | |
| 94 | 94 | return [ |
| 95 | - 'width' => (int)$size->getWidth(), |
|
| 96 | - 'height' => (int)$size->getHeight(), |
|
| 95 | + 'width' => (int) $size->getWidth(), |
|
| 96 | + 'height' => (int) $size->getHeight(), |
|
| 97 | 97 | ]; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -115,8 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | if ($this->driverIsLocal) { |
| 117 | 117 | $this->$method($image, $width, $height)->save($saveTo); |
| 118 | - } |
|
| 119 | - else { |
|
| 118 | + } else { |
|
| 120 | 119 | list($path, $name) = $this->splitPath($saveTo); |
| 121 | 120 | |
| 122 | 121 | $tempDir = $this->tempDir(); |
@@ -360,8 +359,7 @@ discard block |
||
| 360 | 359 | |
| 361 | 360 | if ($file instanceof UploadedFile) { |
| 362 | 361 | $path = $file->getRealPath(); |
| 363 | - } |
|
| 364 | - else if (file_exists($file)) { |
|
| 362 | + } else if (file_exists($file)) { |
|
| 365 | 363 | $path = $file; |
| 366 | 364 | } |
| 367 | 365 | |
@@ -371,8 +369,7 @@ discard block |
||
| 371 | 369 | return self::toHexString($color); |
| 372 | 370 | } |
| 373 | 371 | } |
| 374 | - } |
|
| 375 | - catch (Exception $e) { |
|
| 372 | + } catch (Exception $e) { |
|
| 376 | 373 | // do nothing |
| 377 | 374 | } |
| 378 | 375 | |
@@ -121,8 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | if ($attachment = $this->getAttachment($key)) { |
| 123 | 123 | $attachment->attach($value); |
| 124 | - } |
|
| 125 | - else { |
|
| 124 | + } else { |
|
| 126 | 125 | parent::setAttribute($key, $value); |
| 127 | 126 | } |
| 128 | 127 | } |
@@ -156,8 +155,7 @@ discard block |
||
| 156 | 155 | } |
| 157 | 156 | |
| 158 | 157 | return null; |
| 159 | - } |
|
| 160 | - else { |
|
| 158 | + } else { |
|
| 161 | 159 | $attachments = new stdClass(); |
| 162 | 160 | foreach ($this->attachments as $attachment) { |
| 163 | 161 | $attachments->{$attachment->getName()} = $attachment->urls(); |
@@ -208,8 +206,7 @@ discard block |
||
| 208 | 206 | unset($array["{$name}_file_dominant_color"]); |
| 209 | 207 | unset($array["{$name}_file_format"]); |
| 210 | 208 | unset($array["{$name}_file_cover"]); |
| 211 | - } |
|
| 212 | - else { |
|
| 209 | + } else { |
|
| 213 | 210 | unset($array["{$name}_file_meta"]); |
| 214 | 211 | } |
| 215 | 212 | } |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | $table->string("{$name}_file_dominant_color", 7)->nullable(); |
| 31 | 31 | $table->string("{$name}_file_format", 85)->nullable(); |
| 32 | 32 | $table->string("{$name}_file_cover", 85)->nullable(); |
| 33 | - } |
|
| 34 | - else { |
|
| 33 | + } else { |
|
| 35 | 34 | $table->{self::jsonColumnType()}("{$name}_file_meta")->nullable(); |
| 36 | 35 | } |
| 37 | 36 | } |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | $coverColumns = [ |
| 67 | 66 | "{$name}_file_size", "{$name}_file_type", "{$name}_file_mime_type", "{$name}_file_width", "{$name}_file_height", "{$name}_file_duration", "{$name}_file_format", "{$name}_file_cover" |
| 68 | 67 | ]; |
| 69 | - } |
|
| 70 | - else { |
|
| 68 | + } else { |
|
| 71 | 69 | $coverColumns = [ |
| 72 | 70 | "{$name}_file_size", "{$name}_file_type", "{$name}_file_mime_type", "{$name}_file_width", "{$name}_file_height", "{$name}_file_duration", "{$name}_file_format", "{$name}_file_cover" |
| 73 | 71 | ]; |
@@ -65,8 +65,7 @@ |
||
| 65 | 65 | { |
| 66 | 66 | if ($this->internalFunctionIsCallable) { |
| 67 | 67 | parent::handleFFMpegQueue($isLastOne); |
| 68 | - } |
|
| 69 | - else { |
|
| 68 | + } else { |
|
| 70 | 69 | self::internalException(); |
| 71 | 70 | } |
| 72 | 71 | } |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | try { |
| 51 | 51 | if (isset($this->standalone) and $this->standalone) { |
| 52 | 52 | $this->standalone->handleFFMpegQueue(); |
| 53 | - } |
|
| 54 | - else { |
|
| 53 | + } else { |
|
| 55 | 54 | $class = $this->model; |
| 56 | 55 | $modelNotSaved = true; |
| 57 | 56 | |
@@ -75,8 +74,7 @@ discard block |
||
| 75 | 74 | } |
| 76 | 75 | |
| 77 | 76 | $this->updateStatus(true, false); |
| 78 | - } |
|
| 79 | - catch (FileNotFoundException | Exception $e) { |
|
| 77 | + } catch (FileNotFoundException | Exception $e) { |
|
| 80 | 78 | $this->updateStatus(false, false, $e->getMessage()); |
| 81 | 79 | |
| 82 | 80 | throw new Exception($e->getMessage()); |
@@ -599,12 +599,12 @@ discard block |
||
| 599 | 599 | $unit = substr($number, -1); |
| 600 | 600 | |
| 601 | 601 | if (!array_key_exists($unit, $units)) { |
| 602 | - return (int)$number; |
|
| 602 | + return (int) $number; |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - $number = (float)$number * $units[$unit]; |
|
| 605 | + $number = (float) $number * $units[$unit]; |
|
| 606 | 606 | |
| 607 | - return (int)$number; |
|
| 607 | + return (int) $number; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | */ |
| 731 | 731 | protected function outputToObject(): object |
| 732 | 732 | { |
| 733 | - $output = (object)$this->output; |
|
| 733 | + $output = (object) $this->output; |
|
| 734 | 734 | |
| 735 | 735 | if ($this->camelCaseResponse) { |
| 736 | 736 | $output->mimeType = $output->mime_type; |
@@ -361,8 +361,7 @@ |
||
| 361 | 361 | foreach ($this->output as $key => $value) { |
| 362 | 362 | $this->output[$key] = $model->{"{$this->name}_file_$key"}; |
| 363 | 363 | } |
| 364 | - } |
|
| 365 | - else { |
|
| 364 | + } else { |
|
| 366 | 365 | $meta = json_decode($model->{"{$this->name}_file_meta"}, true); |
| 367 | 366 | |
| 368 | 367 | if (is_array($meta)) { |
@@ -93,11 +93,11 @@ |
||
| 93 | 93 | throw new Exception('stream name [' . $name . '] should be an alpha numeric string'); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if($width <= 0) { |
|
| 96 | + if ($width <= 0) { |
|
| 97 | 97 | throw new Exception('width [' . $width . '] should be a positive number'); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if($height <= 0) { |
|
| 100 | + if ($height <= 0) { |
|
| 101 | 101 | throw new Exception('height [' . $height . '] should be a positive number'); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -35,17 +35,13 @@ discard block |
||
| 35 | 35 | if ($mime) { |
| 36 | 36 | if (strstr($mime, 'image/')) { |
| 37 | 37 | return LaruploadEnum::IMAGE; |
| 38 | - } |
|
| 39 | - else if (strstr($mime, 'video/')) { |
|
| 38 | + } else if (strstr($mime, 'video/')) { |
|
| 40 | 39 | return LaruploadEnum::VIDEO; |
| 41 | - } |
|
| 42 | - else if (strstr($mime, 'audio/')) { |
|
| 40 | + } else if (strstr($mime, 'audio/')) { |
|
| 43 | 41 | return LaruploadEnum::AUDIO; |
| 44 | - } |
|
| 45 | - else if ($mime == 'application/pdf') { |
|
| 42 | + } else if ($mime == 'application/pdf') { |
|
| 46 | 43 | return LaruploadEnum::PDF; |
| 47 | - } |
|
| 48 | - else if ($mime == 'application/zip' or $mime == 'application/x-rar-compressed') { |
|
| 44 | + } else if ($mime == 'application/zip' or $mime == 'application/x-rar-compressed') { |
|
| 49 | 45 | return LaruploadEnum::COMPRESSED; |
| 50 | 46 | } |
| 51 | 47 | } |
@@ -94,11 +90,9 @@ discard block |
||
| 94 | 90 | { |
| 95 | 91 | if (ini_get('upload_tmp_dir')) { |
| 96 | 92 | $path = ini_get('upload_tmp_dir'); |
| 97 | - } |
|
| 98 | - else if (getenv('temp')) { |
|
| 93 | + } else if (getenv('temp')) { |
|
| 99 | 94 | $path = getenv('temp'); |
| 100 | - } |
|
| 101 | - else { |
|
| 95 | + } else { |
|
| 102 | 96 | $path = sys_get_temp_dir(); |
| 103 | 97 | } |
| 104 | 98 | |