Completed
Pull Request — master (#93)
by
unknown
01:17
created
src/bulletproof.php 1 patch
Braces   +22 added lines, -44 removed lines patch added patch discarded remove patch
@@ -112,8 +112,7 @@  discard block
 block discarded – undo
112 112
     /**
113 113
      * @param array $_files represents the $_FILES array passed as dependency
114 114
      */
115
-    public function __construct(array $_files = array())
116
-    {
115
+    public function __construct(array $_files = array()) {
117 116
       if (!function_exists('exif_imagetype')) {
118 117
         $this->error = $this->commonUploadErrors[$this->language]['ERROR_01'];
119 118
       }
@@ -150,8 +149,7 @@  discard block
 block discarded – undo
150 149
      *
151 150
      * @return string|bool
152 151
      */
153
-    public function offsetGet($offset)
154
-    {
152
+    public function offsetGet($offset) {
155 153
       // return false if $_FILES['key'] isn't found
156 154
       if (!isset($this->_files[$offset])) {
157 155
         $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_02'], $offset);
@@ -176,8 +174,7 @@  discard block
 block discarded – undo
176 174
      *
177 175
      * @return $this
178 176
      */
179
-    public function setDimension($maxWidth, $maxHeight)
180
-    {
177
+    public function setDimension($maxWidth, $maxHeight) {
181 178
       if ( (int) $maxWidth && (int) $maxHeight) {
182 179
         $this->dimensions = array($maxWidth, $maxHeight);
183 180
       } else {
@@ -192,8 +189,7 @@  discard block
 block discarded – undo
192 189
      *
193 190
      * @return string
194 191
      */
195
-    public function getFullPath()
196
-    {
192
+    public function getFullPath() {
197 193
       return $this->fullPath = $this->getLocation().'/'.$this->getName().'.'.$this->getMime();
198 194
     }
199 195
 
@@ -204,8 +200,7 @@  discard block
 block discarded – undo
204 200
      *
205 201
      * @return $this
206 202
      */
207
-    public function setLanguage($lang)
208
-    {
203
+    public function setLanguage($lang) {
209 204
       if (isset($this->commonUploadErrors[$lang])) {
210 205
         $this->language = $lang;
211 206
       } else {
@@ -220,8 +215,7 @@  discard block
 block discarded – undo
220 215
      *
221 216
      * @return int
222 217
      */
223
-    public function getSize()
224
-    {
218
+    public function getSize() {
225 219
       return (int) $this->_files['size'];
226 220
     }
227 221
 
@@ -233,8 +227,7 @@  discard block
 block discarded – undo
233 227
      *
234 228
      * @return $this
235 229
      */
236
-    public function setSize($min, $max)
237
-    {
230
+    public function setSize($min, $max) {
238 231
       $this->size = array($min, $max);
239 232
       return $this;
240 233
     }
@@ -244,8 +237,7 @@  discard block
 block discarded – undo
244 237
      *
245 238
      * @return string
246 239
      */
247
-    public function getJson()
248
-    {
240
+    public function getJson() {
249 241
       return json_encode(
250 242
         array(
251 243
           'name' => $this->name,
@@ -264,8 +256,7 @@  discard block
 block discarded – undo
264 256
      *
265 257
      * @return null|string
266 258
      */
267
-    public function getMime()
268
-    {
259
+    public function getMime() {
269 260
       if (!$this->mime) {
270 261
         $this->mime = $this->getImageMime($this->_files['tmp_name']);
271 262
       }
@@ -280,8 +271,7 @@  discard block
 block discarded – undo
280 271
      *
281 272
      * @return $this
282 273
      */
283
-    public function setMime(array $fileTypes)
284
-    {
274
+    public function setMime(array $fileTypes) {
285 275
       $this->mimeTypes = $fileTypes;
286 276
       return $this;
287 277
     }
@@ -293,8 +283,7 @@  discard block
 block discarded – undo
293 283
      *
294 284
      * @return null|string
295 285
      */
296
-    protected function getImageMime($tmp_name)
297
-    {
286
+    protected function getImageMime($tmp_name) {
298 287
       $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)];
299 288
       if (!$this->mime) {
300 289
         return null;
@@ -308,8 +297,7 @@  discard block
 block discarded – undo
308 297
      *
309 298
      * @return string|false
310 299
      */
311
-    public function getError()
312
-    {
300
+    public function getError() {
313 301
       return $this->error;
314 302
     }
315 303
 
@@ -318,8 +306,7 @@  discard block
 block discarded – undo
318 306
      *
319 307
      * @return string
320 308
      */
321
-    public function getName()
322
-    {
309
+    public function getName() {
323 310
       if (!$this->name) {
324 311
         $this->name = uniqid('', true).'_'.str_shuffle(implode(range('e', 'q')));
325 312
       }
@@ -334,8 +321,7 @@  discard block
 block discarded – undo
334 321
      *
335 322
      * @return $this
336 323
      */
337
-    public function setName($isNameProvided = null)
338
-    {
324
+    public function setName($isNameProvided = null) {
339 325
       if ($isNameProvided) {
340 326
         $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
341 327
       }
@@ -348,8 +334,7 @@  discard block
 block discarded – undo
348 334
      *
349 335
      * @return int
350 336
      */
351
-    public function getWidth()
352
-    {
337
+    public function getWidth() {
353 338
       if ($this->width != null) {
354 339
         return $this->width;
355 340
       }
@@ -364,8 +349,7 @@  discard block
 block discarded – undo
364 349
      *
365 350
      * @return int
366 351
      */
367
-    public function getHeight()
368
-    {
352
+    public function getHeight() {
369 353
       if ($this->height != null) {
370 354
         return $this->height;
371 355
       }
@@ -380,8 +364,7 @@  discard block
 block discarded – undo
380 364
      *
381 365
      * @return string
382 366
      */
383
-    public function getLocation()
384
-    {
367
+    public function getLocation() {
385 368
       if (!$this->location) {
386 369
         $this->setLocation();
387 370
       }
@@ -396,8 +379,7 @@  discard block
 block discarded – undo
396 379
      *
397 380
      * @return bool
398 381
      */
399
-    private function isDirectoryValid($dir)
400
-    {
382
+    private function isDirectoryValid($dir) {
401 383
       return !file_exists($dir) && !is_dir($dir) || is_writable($dir);
402 384
     }
403 385
 
@@ -409,8 +391,7 @@  discard block
 block discarded – undo
409 391
      *
410 392
      * @return $this
411 393
      */
412
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
413
-    {
394
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
414 395
       $isDirectoryValid = $this->isDirectoryValid($dir);
415 396
 
416 397
       if (!$isDirectoryValid) {
@@ -435,8 +416,7 @@  discard block
 block discarded – undo
435 416
      *
436 417
      * @return boolean
437 418
      */
438
-    protected function contraintsValidator()
439
-    {
419
+    protected function contraintsValidator() {
440 420
       /* check image for valid mime types and return mime */
441 421
       $this->getImageMime($this->_files['tmp_name']);
442 422
       /* validate image mime type */
@@ -474,8 +454,7 @@  discard block
 block discarded – undo
474 454
      *
475 455
      * @return false|Image
476 456
      */
477
-    public function upload()
478
-    {
457
+    public function upload() {
479 458
       if ($this->error) {
480 459
         return false;
481 460
       }
@@ -495,8 +474,7 @@  discard block
 block discarded – undo
495 474
      *
496 475
      * @return bool
497 476
      */
498
-    protected function isSaved($tmp_name, $destination)
499
-    {
477
+    protected function isSaved($tmp_name, $destination) {
500 478
       return move_uploaded_file($tmp_name, $destination);
501 479
     }
502 480
 }
503 481
\ No newline at end of file
Please login to merge, or discard this patch.