Passed
Push — master ( d235db...d29806 )
by samayo
02:10 queued 52s
created
src/bulletproof.php 1 patch
Braces   +21 added lines, -41 removed lines patch added patch discarded remove patch
@@ -96,8 +96,7 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * @param array $_files represents the $_FILES array passed as dependency
98 98
      */
99
-    public function __construct(array $_files = array())
100
-    {
99
+    public function __construct(array $_files = array()) {
101 100
 
102 101
         /* check if php_exif is enabled */
103 102
         if (!function_exists('exif_imagetype')) {
@@ -164,8 +163,7 @@  discard block
 block discarded – undo
164 163
      *
165 164
      * @return $this
166 165
      */
167
-    public function setDimension($maxWidth, $maxHeight)
168
-    {
166
+    public function setDimension($maxWidth, $maxHeight) {
169 167
       $this->dimensions = array($maxWidth, $maxHeight);
170 168
 
171 169
       return $this;
@@ -176,8 +174,7 @@  discard block
 block discarded – undo
176 174
      *
177 175
      * @return string
178 176
      */
179
-    public function getPath()
180
-    {
177
+    public function getPath() {
181 178
       return $this->path = $this->getStorage() . '/' . $this->getName() . '.' . $this->getMime();
182 179
     }
183 180
 
@@ -186,8 +183,7 @@  discard block
 block discarded – undo
186 183
      *
187 184
      * @return int
188 185
      */
189
-    public function getSize()
190
-    {
186
+    public function getSize() {
191 187
       return (int) $this->_files['size'];
192 188
     }
193 189
 
@@ -199,8 +195,7 @@  discard block
 block discarded – undo
199 195
      *
200 196
      * @return $this
201 197
      */
202
-    public function setSize($min, $max)
203
-    {
198
+    public function setSize($min, $max) {
204 199
       $this->size = array($min, $max);
205 200
       return $this;
206 201
     }
@@ -210,8 +205,7 @@  discard block
 block discarded – undo
210 205
      *
211 206
      * @return string
212 207
      */
213
-    public function getJson()
214
-    {
208
+    public function getJson() {
215 209
       return json_encode(
216 210
         array(
217 211
           'name' => $this->name,
@@ -230,8 +224,7 @@  discard block
 block discarded – undo
230 224
      *
231 225
      * @return null|string
232 226
      */
233
-    public function getMime()
234
-    {
227
+    public function getMime() {
235 228
       if (!$this->mime) {
236 229
         $this->mime = $this->getImageMime($this->_files['tmp_name']);
237 230
       }
@@ -246,8 +239,7 @@  discard block
 block discarded – undo
246 239
      *
247 240
      * @return $this
248 241
      */
249
-    public function setMime(array $fileTypes)
250
-    {
242
+    public function setMime(array $fileTypes) {
251 243
       $this->mimeTypes = $fileTypes;
252 244
       return $this;
253 245
     }
@@ -259,8 +251,7 @@  discard block
 block discarded – undo
259 251
      *
260 252
      * @return null|string
261 253
      */
262
-    protected function getImageMime($tmp_name)
263
-    {
254
+    protected function getImageMime($tmp_name) {
264 255
       $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)];
265 256
       if (!$this->mime) {
266 257
         return null;
@@ -274,8 +265,7 @@  discard block
 block discarded – undo
274 265
      *
275 266
      * @return string
276 267
      */
277
-    public function getError()
278
-    {
268
+    public function getError() {
279 269
       return $this->error;
280 270
     }
281 271
 
@@ -284,8 +274,7 @@  discard block
 block discarded – undo
284 274
      *
285 275
      * @return string
286 276
      */
287
-    public function getName()
288
-    {
277
+    public function getName() {
289 278
       return $this->name;
290 279
     }
291 280
 
@@ -296,11 +285,10 @@  discard block
 block discarded – undo
296 285
      *
297 286
      * @return $this
298 287
      */
299
-    public function setName($isNameProvided = null)
300
-    {
288
+    public function setName($isNameProvided = null) {
301 289
       if ($isNameProvided) {
302 290
         $this->name = $isNameProvided;
303
-      }else{
291
+      } else{
304 292
         $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
305 293
       }
306 294
 
@@ -312,8 +300,7 @@  discard block
 block discarded – undo
312 300
      *
313 301
      * @return int
314 302
      */
315
-    public function getWidth()
316
-    {
303
+    public function getWidth() {
317 304
       if ($this->width != null) {
318 305
         return $this->width;
319 306
       }
@@ -328,8 +315,7 @@  discard block
 block discarded – undo
328 315
      *
329 316
      * @return int
330 317
      */
331
-    public function getHeight()
332
-    {
318
+    public function getHeight() {
333 319
       if ($this->height != null) {
334 320
         return $this->height;
335 321
       }
@@ -344,8 +330,7 @@  discard block
 block discarded – undo
344 330
      *
345 331
      * @return string
346 332
      */
347
-    public function getStorage()
348
-    {
333
+    public function getStorage() {
349 334
       if (!$this->storage) {
350 335
         $this->setStorage();
351 336
       }
@@ -360,8 +345,7 @@  discard block
 block discarded – undo
360 345
      *
361 346
      * @return bool
362 347
      */
363
-    private function isDirectoryValid($dir)
364
-    {
348
+    private function isDirectoryValid($dir) {
365 349
       return !file_exists($dir) && !is_dir($dir) || is_writable($dir);
366 350
     }
367 351
 
@@ -373,8 +357,7 @@  discard block
 block discarded – undo
373 357
      *
374 358
      * @return $this
375 359
      */
376
-    public function setStorage($dir = 'uploads', $permission = 0666)
377
-    {
360
+    public function setStorage($dir = 'uploads', $permission = 0666) {
378 361
       $isDirectoryValid = $this->isDirectoryValid($dir);
379 362
 
380 363
       if (!$isDirectoryValid) {
@@ -399,8 +382,7 @@  discard block
 block discarded – undo
399 382
      *
400 383
      * @return boolean
401 384
      */
402
-    protected function constraintValidator()
403
-    { 
385
+    protected function constraintValidator() {
404 386
 
405 387
       // if name is provided use it, otherwise generate a unique name
406 388
       if (!$this->name) {
@@ -447,8 +429,7 @@  discard block
 block discarded – undo
447 429
      *
448 430
      * @return false|Image
449 431
      */
450
-    public function upload()
451
-    {
432
+    public function upload() {
452 433
       if ($this->error !== '') {
453 434
         return false;
454 435
       }
@@ -469,8 +450,7 @@  discard block
 block discarded – undo
469 450
      *
470 451
      * @return bool
471 452
      */
472
-    protected function isSaved($tmp_name, $destination)
473
-    {
453
+    protected function isSaved($tmp_name, $destination) {
474 454
       return move_uploaded_file($tmp_name, $destination);
475 455
     }
476 456
 }
477 457
\ No newline at end of file
Please login to merge, or discard this patch.