Completed
Push — master ( 69506e...313577 )
by samayo
01:17
created
src/bulletproof.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function getFullPath()
197 197
     {
198
-        $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime;
198
+        $this->fullPath = $this->location.'/'.$this->name.'.'.$this->mime;
199 199
         return $this->fullPath;
200 200
     }
201 201
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function getSize()
208 208
     {
209
-        return (int)$this->_files['size'];
209
+        return (int) $this->_files['size'];
210 210
     }
211 211
 
212 212
     /**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         if ($files['size'] < $minSize || $files['size'] > $maxSize) {
324 324
             $min = intval($minSize / 1000) ?: 1;
325 325
             $max = intval($maxSize / 1000) ?: 1;
326
-            $image->error = 'Image size should be at least ' . $min . ' KB, and no more than ' . $max . ' KB';
326
+            $image->error = 'Image size should be at least '.$min.' KB, and no more than '.$max.' KB';
327 327
             return null;
328 328
         }
329 329
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         list($allowedWidth, $allowedHeight) = $image->dimensions;
332 332
 
333 333
         if ($image->height > $allowedHeight || $image->width > $allowedWidth) {
334
-            $image->error = 'Image height/width should be less than ' . $allowedHeight . '/' . $allowedWidth . ' pixels';
334
+            $image->error = 'Image height/width should be less than '.$allowedHeight.'/'.$allowedWidth.' pixels';
335 335
             return false;
336 336
         }
337 337
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         }
342 342
 
343 343
         /* set and get folder name */
344
-        $image->fullPath = $image->location . '/' . $image->name . '.' . $image->mime;
344
+        $image->fullPath = $image->location.'/'.$image->name.'.'.$image->mime;
345 345
 
346 346
         /* gather image info for json storage */
347 347
         $image->serialize = array(
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
     public function getName()
374 374
     {
375 375
         if (!$this->name) {
376
-            return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
376
+            return uniqid('', true).'_'.str_shuffle(implode(range('e', 'q')));
377 377
         }
378 378
 
379 379
         return $this->name;
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
     {
451 451
 
452 452
         if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
453
-            $createFolder = @mkdir('' . $dir, (int)$permission, true);
453
+            $createFolder = @mkdir(''.$dir, (int) $permission, true);
454 454
             if (!$createFolder) {
455
-                $this->error = 'Error! Folder ' . $dir . ' could not be created';
455
+                $this->error = 'Error! Folder '.$dir.' could not be created';
456 456
                 return false;
457 457
             }
458 458
         }
459 459
 
460 460
         /* check if we can create a file in the directory */
461 461
         if (!is_writable($dir)) {
462
-            $this->error = 'The images directory \'' . $dir . '\' is not writable!';
462
+            $this->error = 'The images directory \''.$dir.'\' is not writable!';
463 463
             return false;
464 464
         }
465 465
 
Please login to merge, or discard this patch.
Braces   +23 added lines, -46 removed lines patch added patch discarded remove patch
@@ -99,8 +99,7 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * @param array $_files represents the $_FILES array passed as dependency
101 101
      */
102
-    public function __construct(array $_files = array())
103
-    {
102
+    public function __construct(array $_files = array()) {
104 103
         /* check if php_exif is enabled */
105 104
         if (!function_exists('exif_imagetype')) {
106 105
             $this->error = 'Function \'exif_imagetype\' Not found. Please enable \'php_exif\' in your PHP.ini';
@@ -114,23 +113,20 @@  discard block
 block discarded – undo
114 113
      * @param mixed $offset
115 114
      * @param mixed $value
116 115
      */
117
-    public function offsetSet($offset, $value)
118
-    {
116
+    public function offsetSet($offset, $value) {
119 117
     }
120 118
 
121 119
     /**
122 120
      * @param mixed $offset
123 121
      * @return null
124 122
      */
125
-    public function offsetExists($offset)
126
-    {
123
+    public function offsetExists($offset) {
127 124
     }
128 125
 
129 126
     /**
130 127
      * @param mixed $offset
131 128
      */
132
-    public function offsetUnset($offset)
133
-    {
129
+    public function offsetUnset($offset) {
134 130
     }
135 131
 
136 132
     /**
@@ -140,8 +136,7 @@  discard block
 block discarded – undo
140 136
      *
141 137
      * @return string|boolean
142 138
      */
143
-    public function offsetGet($offset)
144
-    {   
139
+    public function offsetGet($offset) {
145 140
         /* return error if requested */
146 141
         if ($offset == 'error') {
147 142
             return $this->error;
@@ -169,8 +164,7 @@  discard block
 block discarded – undo
169 164
      *
170 165
      * @return string
171 166
      */
172
-    protected function commonUploadErrors($errors)
173
-    {
167
+    protected function commonUploadErrors($errors) {
174 168
         return $this->common_upload_errors[$errors];
175 169
     }
176 170
 
@@ -182,8 +176,7 @@  discard block
 block discarded – undo
182 176
      *
183 177
      * @return $this
184 178
      */
185
-    public function setDimension($maxWidth, $maxHeight)
186
-    {
179
+    public function setDimension($maxWidth, $maxHeight) {
187 180
         $this->dimensions = array($maxWidth, $maxHeight);
188 181
         return $this;
189 182
     }
@@ -193,8 +186,7 @@  discard block
 block discarded – undo
193 186
      *
194 187
      * @return string
195 188
      */
196
-    public function getFullPath()
197
-    {
189
+    public function getFullPath() {
198 190
         $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime;
199 191
         return $this->fullPath;
200 192
     }
@@ -204,8 +196,7 @@  discard block
 block discarded – undo
204 196
      *
205 197
      * @return int
206 198
      */
207
-    public function getSize()
208
-    {
199
+    public function getSize() {
209 200
         return (int)$this->_files['size'];
210 201
     }
211 202
 
@@ -217,8 +208,7 @@  discard block
 block discarded – undo
217 208
      *
218 209
      * @return $this
219 210
      */
220
-    public function setSize($min, $max)
221
-    {
211
+    public function setSize($min, $max) {
222 212
         $this->size = array($min, $max);
223 213
         return $this;
224 214
     }
@@ -228,8 +218,7 @@  discard block
 block discarded – undo
228 218
      *
229 219
      * @return string
230 220
      */
231
-    public function getJson()
232
-    {
221
+    public function getJson() {
233 222
         return json_encode($this->serialize);
234 223
     }
235 224
 
@@ -238,8 +227,7 @@  discard block
 block discarded – undo
238 227
      *
239 228
      * @return null|string
240 229
      */
241
-    public function getMime()
242
-    {
230
+    public function getMime() {
243 231
         if (!$this->mime) {
244 232
             return $this->getImageMime($this->_files['tmp_name']);
245 233
         }
@@ -253,8 +241,7 @@  discard block
 block discarded – undo
253 241
      *
254 242
      * @return $this
255 243
      */
256
-    public function setMime(array $fileTypes)
257
-    {
244
+    public function setMime(array $fileTypes) {
258 245
         $this->mimeTypes = $fileTypes;
259 246
         return $this;
260 247
     }
@@ -266,8 +253,7 @@  discard block
 block discarded – undo
266 253
      *
267 254
      * @return null|string
268 255
      */
269
-    protected function getImageMime($tmp_name)
270
-    {
256
+    protected function getImageMime($tmp_name) {
271 257
         $mime = @$this->imageMimes[exif_imagetype($tmp_name)];
272 258
 
273 259
         if (!$mime) {
@@ -282,8 +268,7 @@  discard block
 block discarded – undo
282 268
      *
283 269
      * @return string|false
284 270
      */
285
-    public function getError()
286
-    {
271
+    public function getError() {
287 272
         return $this->error != '' ? $this->error : false;
288 273
     }
289 274
 
@@ -291,8 +276,7 @@  discard block
 block discarded – undo
291 276
      * This methods validates and uploads the image
292 277
      * @return false|Image
293 278
      */
294
-    public function upload()
295
-    {
279
+    public function upload() {
296 280
         /* modify variable names for convenience */
297 281
         $image = $this;
298 282
         $files = $this->_files;
@@ -370,8 +354,7 @@  discard block
 block discarded – undo
370 354
      *
371 355
      * @return string
372 356
      */
373
-    public function getName()
374
-    {
357
+    public function getName() {
375 358
         if (!$this->name) {
376 359
             return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
377 360
         }
@@ -385,8 +368,7 @@  discard block
 block discarded – undo
385 368
      * @param null $isNameProvided
386 369
      * @return $this
387 370
      */
388
-    public function setName($isNameProvided = null)
389
-    {
371
+    public function setName($isNameProvided = null) {
390 372
         if ($isNameProvided) {
391 373
             $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
392 374
         }
@@ -399,8 +381,7 @@  discard block
 block discarded – undo
399 381
      *
400 382
      * @return int
401 383
      */
402
-    public function getWidth()
403
-    {
384
+    public function getWidth() {
404 385
         if ($this->width != null) {
405 386
             return $this->width;
406 387
         }
@@ -414,8 +395,7 @@  discard block
 block discarded – undo
414 395
      *
415 396
      * @return int
416 397
      */
417
-    public function getHeight()
418
-    {
398
+    public function getHeight() {
419 399
         if ($this->height != null) {
420 400
             return $this->height;
421 401
         }
@@ -429,8 +409,7 @@  discard block
 block discarded – undo
429 409
      *
430 410
      * @return string
431 411
      */
432
-    public function getLocation()
433
-    {
412
+    public function getLocation() {
434 413
         if (!$this->location) {
435 414
             $this->setLocation();
436 415
         }
@@ -446,8 +425,7 @@  discard block
 block discarded – undo
446 425
      *
447 426
      * @return $this
448 427
      */
449
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
450
-    {
428
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
451 429
 
452 430
         if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
453 431
             $createFolder = @mkdir('' . $dir, (int)$permission, true);
@@ -475,8 +453,7 @@  discard block
 block discarded – undo
475 453
      *
476 454
      * @return bool
477 455
      */
478
-    public function moveUploadedFile($tmp_name, $destination)
479
-    {
456
+    public function moveUploadedFile($tmp_name, $destination) {
480 457
         return move_uploaded_file($tmp_name, $destination);
481 458
     }
482 459
 }
483 460
\ No newline at end of file
Please login to merge, or discard this patch.