1212class Strategy
1313{
1414 protected string $ disk ;
15+
1516 protected string $ directory ;
17+
1618 protected array $ mimes = [];
19+
1720 protected string $ name ;
21+
1822 protected int $ maxSize = 0 ;
23+
1924 protected string $ filenameType ;
25+
2026 protected UploadedFile $ file ;
2127
22- /**
23- * @param array $config
24- * @param UploadedFile $file
25- */
2628 public function __construct (array $ config , UploadedFile $ file )
2729 {
2830 $ config = new Fluent ($ config );
@@ -117,18 +119,16 @@ public function isValidSize()
117119
118120 public function validate ()
119121 {
120- if (!$ this ->isValidMime ()) {
122+ if (! $ this ->isValidMime ()) {
121123 \abort (422 , \sprintf ('Invalid mime "%s". ' , $ this ->file ->getClientMimeType ()));
122124 }
123125
124- if (!$ this ->isValidSize ()) {
126+ if (! $ this ->isValidSize ()) {
125127 \abort (422 , \sprintf ('File has too large size("%s"). ' , $ this ->file ->getSize ()));
126128 }
127129 }
128130
129131 /**
130- * @param array $options
131- *
132132 * @return \Overtrue\LaravelUploader\Response
133133 */
134134 public function upload (array $ options = [])
@@ -156,7 +156,6 @@ public function upload(array $options = [])
156156 /**
157157 * Replace date variable in dir path.
158158 *
159- * @param string $dir
160159 *
161160 * @return string
162161 */
@@ -176,23 +175,22 @@ protected function formatDirectory(string $dir)
176175
177176 /**
178177 * @param mixed $humanFileSize
179- *
180178 * @return int
181179 */
182180 protected function filesize2bytes ($ humanFileSize )
183181 {
184- $ bytesUnits = array (
182+ $ bytesUnits = [
185183 'K ' => 1024 ,
186184 'M ' => 1024 * 1024 ,
187185 'G ' => 1024 * 1024 * 1024 ,
188186 'T ' => 1024 * 1024 * 1024 * 1024 ,
189187 'P ' => 1024 * 1024 * 1024 * 1024 * 1024 ,
190- ) ;
188+ ] ;
191189
192190 $ bytes = floatval ($ humanFileSize );
193191
194192 if (preg_match ('~([KMGTP])$~si ' , rtrim ($ humanFileSize , 'B ' ), $ matches )
195- && !empty ($ bytesUnits [\strtoupper ($ matches [1 ])])) {
193+ && ! empty ($ bytesUnits [\strtoupper ($ matches [1 ])])) {
196194 $ bytes *= $ bytesUnits [\strtoupper ($ matches [1 ])];
197195 }
198196
0 commit comments