@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | use wapmorgan\UnifiedArchive\UnifiedArchive; |
| 30 | 30 | use AYazdanpanah\SaveUploadedFiles\Exception\Exception; |
| 31 | 31 | |
| 32 | -if(isset($_POST['submit'])) { |
|
| 32 | +if (isset($_POST['submit'])) { |
|
| 33 | 33 | |
| 34 | 34 | $user_id = rand(10000, 1000000); |
| 35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @return ImageResize |
| 42 | 42 | */ |
| 43 | 43 | $image_path = __DIR__ . "/images/user/$user_id"; |
| 44 | - $export_image = function ($filename) use ($image_path) { |
|
| 44 | + $export_image = function($filename) use ($image_path) { |
|
| 45 | 45 | //Add a Validator: check if the file is image |
| 46 | 46 | if (!is_type("image", $filename)) { |
| 47 | 47 | throw new Exception("Your file is not an image!"); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | $video_path = __DIR__ . "/videos/$user_id"; |
| 79 | 79 | $video_name = str_random(); |
| 80 | - $export_video = function ($filename) use ($video_path, $video_name) { |
|
| 80 | + $export_video = function($filename) use ($video_path, $video_name) { |
|
| 81 | 81 | |
| 82 | 82 | $video = AYazdanpanah\FFMpegStreaming\FFMpeg::create() |
| 83 | 83 | ->open($filename); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | //Add a Validator: check if the video is HD or higher resolution |
| 94 | - if ($video_metadata->get('width',1) * $video_metadata->get('height', 1) < 1280 * 720) { |
|
| 94 | + if ($video_metadata->get('width', 1) * $video_metadata->get('height', 1) < 1280 * 720) { |
|
| 95 | 95 | throw new Exception("Sorry, your video must be at least HD or higher resolution"); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | //Create the dash files(it is better to create a job and dispatch it-do it in the background) |
| 113 | 113 | mkdir("$video_path/dash/$video_name", 0777, true); |
| 114 | - dash($filename, "$video_path/dash/$video_name/output.mpd", function ($audio, $format, $percentage) { |
|
| 114 | + dash($filename, "$video_path/dash/$video_name/output.mpd", function($audio, $format, $percentage) { |
|
| 115 | 115 | echo "$percentage % transcoded\n"; |
| 116 | 116 | }); |
| 117 | 117 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | $archive_path = __DIR__ . "/archive/$user_id"; |
| 131 | 131 | $archive_name = str_random(); |
| 132 | - $archive_export = function ($filename) use ($archive_path, $archive_name) { |
|
| 132 | + $archive_export = function($filename) use ($archive_path, $archive_name) { |
|
| 133 | 133 | mkdir("$archive_path/$archive_name"); |
| 134 | 134 | $archive = UnifiedArchive::open($filename); |
| 135 | 135 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | $doc_path = __DIR__ . "/docs/$user_id"; |
| 163 | 163 | $doc_name = str_random(); |
| 164 | - $doc_export = function ($filename) use ($doc_path, $doc_name) { |
|
| 164 | + $doc_export = function($filename) use ($doc_path, $doc_name) { |
|
| 165 | 165 | mkdir($doc_path . '/backup'); |
| 166 | 166 | copy($filename, "$doc_path/backup/$doc_name.backup"); |
| 167 | 167 | return ['backup_to' => $doc_path . '/backup']; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | $audio_path = __DIR__ . "/audios/$user_id"; |
| 177 | 177 | $audio_name = str_random(); |
| 178 | - $audio_export = function ($filename) use ($audio_path, $audio_name) { |
|
| 178 | + $audio_export = function($filename) use ($audio_path, $audio_name) { |
|
| 179 | 179 | mkdir($audio_path . '/flac'); |
| 180 | 180 | $audio = AYazdanpanah\FFMpegStreaming\FFMpeg::create() |
| 181 | 181 | ->open($filename); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | //Convert the file into flac format |
| 195 | 195 | $format = new FFMpeg\Format\Audio\Flac(); |
| 196 | 196 | |
| 197 | - $format->on('progress', function ($audio, $format, $percentage) { |
|
| 197 | + $format->on('progress', function($audio, $format, $percentage) { |
|
| 198 | 198 | echo "$percentage % transcoded\n"; |
| 199 | 199 | }); |
| 200 | 200 | |
@@ -23,9 +23,9 @@ |
||
| 23 | 23 | use AYazdanpanah\SaveUploadedFiles\Validator; |
| 24 | 24 | use Gumlet\ImageResize; |
| 25 | 25 | |
| 26 | -if(isset($_POST['submit'])) { |
|
| 26 | +if (isset($_POST['submit'])) { |
|
| 27 | 27 | $image_path = __DIR__ . "/images/user/123456"; |
| 28 | - $export_image = function ($filename) use ($image_path) { |
|
| 28 | + $export_image = function($filename) use ($image_path) { |
|
| 29 | 29 | //Add a Validator: check if the file is image |
| 30 | 30 | if (!is_type("image", $filename)) { |
| 31 | 31 | throw new Exception("Your file is not an image!"); |
@@ -18,4 +18,4 @@ |
||
| 18 | 18 | |
| 19 | 19 | namespace AYazdanpanah\SaveUploadedFiles\Exception; |
| 20 | 20 | |
| 21 | -interface SaveExceptionInterface{} |
|
| 22 | 21 | \ No newline at end of file |
| 22 | +interface SaveExceptionInterface {} |
|
| 23 | 23 | \ No newline at end of file |
@@ -18,4 +18,4 @@ |
||
| 18 | 18 | |
| 19 | 19 | namespace AYazdanpanah\SaveUploadedFiles\Exception; |
| 20 | 20 | |
| 21 | -class Exception extends \Exception implements SaveExceptionInterface{} |
|
| 22 | 21 | \ No newline at end of file |
| 22 | +class Exception extends \Exception implements SaveExceptionInterface {} |
|
| 23 | 23 | \ No newline at end of file |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $save_as = null; |
| 47 | 47 | $export = static::mockCallback(); |
| 48 | 48 | |
| 49 | - if(isset($file['export'])){ |
|
| 49 | + if (isset($file['export'])) { |
|
| 50 | 50 | $export = $file['export']; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | private static function mockCallback(): callable |
| 107 | 107 | { |
| 108 | - return function ($filename){ |
|
| 108 | + return function($filename) { |
|
| 109 | 109 | return $filename; |
| 110 | 110 | }; |
| 111 | 111 | } |
@@ -135,8 +135,8 @@ |
||
| 135 | 135 | 'dir_path' => $this->path, |
| 136 | 136 | 'file_path' => $this->file_path, |
| 137 | 137 | 'upload_datetime' => date("Y-m-d H:i:s"), |
| 138 | - 'stat' => !is_file($this->file_path)?:stat($this->file_path), |
|
| 139 | - 'mime_content_type' => !is_file($this->file_path)?:mime_content_type($this->file_path), |
|
| 138 | + 'stat' => !is_file($this->file_path) ?: stat($this->file_path), |
|
| 139 | + 'mime_content_type' => !is_file($this->file_path) ?: mime_content_type($this->file_path), |
|
| 140 | 140 | 'export' => $this->export_data, |
| 141 | 141 | ] |
| 142 | 142 | ] |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | private function getFile() |
| 43 | 43 | { |
| 44 | 44 | if (!isset($_FILES[$this->filename])) { |
| 45 | - throw new Exception("There is no \"" .$this->filename . "\" key in the \$_FILES. Be sure your key name is correct"); |
|
| 45 | + throw new Exception("There is no \"" . $this->filename . "\" key in the \$_FILES. Be sure your key name is correct"); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if($code = $_FILES[$this->filename]['error']){ |
|
| 48 | + if ($code = $_FILES[$this->filename]['error']) { |
|
| 49 | 49 | $this->throwErrorException($code); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | private function throwErrorException($code) |
| 115 | 115 | { |
| 116 | - switch ($code){ |
|
| 116 | + switch ($code) { |
|
| 117 | 117 | case 1: |
| 118 | 118 | throw new Exception("The uploaded file exceeds the upload_max_filesize directive in php.ini"); |
| 119 | 119 | break; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use AYazdanpanah\SaveUploadedFiles\Upload; |
| 21 | 21 | use AYazdanpanah\SaveUploadedFiles\Filter; |
| 22 | 22 | |
| 23 | -if (! function_exists('uploads')) { |
|
| 23 | +if (!function_exists('uploads')) { |
|
| 24 | 24 | /** |
| 25 | 25 | * @param $config_files |
| 26 | 26 | * @return mixed |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -if (! function_exists('str_random')) { |
|
| 35 | +if (!function_exists('str_random')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * @param int $length |
| 38 | 38 | * @return string |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -if (! function_exists('is_type')) { |
|
| 46 | +if (!function_exists('is_type')) { |
|
| 47 | 47 | /** |
| 48 | 48 | * @param $type |
| 49 | 49 | * @param $filename |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | function is_type($type, $filename): bool |
| 54 | 54 | { |
| 55 | - return Helper::isType($type,$filename); |
|
| 55 | + return Helper::isType($type, $filename); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -if (! function_exists('video_types')) { |
|
| 59 | +if (!function_exists('video_types')) { |
|
| 60 | 60 | /** |
| 61 | 61 | * @return mixed |
| 62 | 62 | */ |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $name = array($name); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return array_filter($this->extractions, function ($key) use ($name) { |
|
| 57 | + return array_filter($this->extractions, function($key) use ($name) { |
|
| 58 | 58 | return in_array($key, $name) || current($name) === "*"; |
| 59 | 59 | }, ARRAY_FILTER_USE_KEY); |
| 60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $name = array($name); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return array_filter($this->extractions, function ($key) use ($name) { |
|
| 74 | + return array_filter($this->extractions, function($key) use ($name) { |
|
| 75 | 75 | return !in_array($key, $name); |
| 76 | 76 | }, ARRAY_FILTER_USE_KEY); |
| 77 | 77 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function succeeded(): array |
| 95 | 95 | { |
| 96 | - return array_filter($this->extractions, function ($detail) { |
|
| 96 | + return array_filter($this->extractions, function($detail) { |
|
| 97 | 97 | return $detail['status']; |
| 98 | 98 | }); |
| 99 | 99 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function failed(): array |
| 107 | 107 | { |
| 108 | - return array_filter($this->extractions, function ($detail) { |
|
| 108 | + return array_filter($this->extractions, function($detail) { |
|
| 109 | 109 | return !$detail['status']; |
| 110 | 110 | }); |
| 111 | 111 | } |