Completed
Push — master ( ace230...37f7ca )
by samayo
01:56
created
src/bulletproof.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
      * @param mixed $offset
135 135
      * @param mixed $value
136 136
      */
137
-    public function offsetSet($offset, $value){}
137
+    public function offsetSet($offset, $value) {}
138 138
 
139 139
     /**
140 140
      * @param mixed $offset
141 141
      * @return null
142 142
      */
143
-    public function offsetExists($offset){}
143
+    public function offsetExists($offset) {}
144 144
 
145 145
     /**
146 146
      * @param mixed $offset
147 147
      */
148
-    public function offsetUnset($offset){}
148
+    public function offsetUnset($offset) {}
149 149
 
150 150
     /**
151 151
      * Gets array value \ArrayAccess
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     public function setLocation($dir = "bulletproof", $permission = 0666)
223 223
     {
224 224
         if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
225
-            $createFolder = @mkdir("" . $dir, (int) $permission, true);
225
+            $createFolder = @mkdir("".$dir, (int) $permission, true);
226 226
             if (!$createFolder) {
227 227
                 $this->error = sprintf($this->error_messages['location'], $dir);
228 228
                 return;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function setErrorMessages($new_error_messages)
258 258
 	{
259
-		if($new_array = array_replace_recursive($this->error_messages, $new_error_messages)) {
259
+		if ($new_array = array_replace_recursive($this->error_messages, $new_error_messages)) {
260 260
 			$this->error_messages = $new_array;
261 261
 		};
262 262
 		return $this;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function getName()
271 271
     {
272 272
         if (!$this->name) {
273
-           return  uniqid(true) . "_" . str_shuffle(implode(range("e", "q")));
273
+           return  uniqid(true)."_".str_shuffle(implode(range("e", "q")));
274 274
         }
275 275
 
276 276
         return $this->name;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function getFullPath()
285 285
     {
286
-        $this->fullPath = $this->location . "/" . $this->name . "." . $this->mime;
286
+        $this->fullPath = $this->location."/".$this->name.".".$this->mime;
287 287
         return $this->fullPath;
288 288
     }
289 289
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      */
335 335
     public function getLocation()
336 336
     {
337
-        if(!$this->location){
337
+        if (!$this->location) {
338 338
             $this->setLocation(); 
339 339
         }
340 340
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      *
367 367
      * @return string|bool
368 368
      */
369
-    public function getError(){
369
+    public function getError() {
370 370
         return $this->error != "" ? $this->error : false;
371 371
     }
372 372
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
         $files = $this->_files;
395 395
 
396 396
         /* check if php_exif is enabled */
397
-        if(!function_exists('exif_imagetype')){
397
+        if (!function_exists('exif_imagetype')) {
398 398
             $image->error = "Function 'exif_imagetype' Not found. Please enable \"php_exif\" in your PHP.ini";
399 399
             return null;
400 400
         }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
         list($minSize, $maxSize) = $image->size;
410 410
 
411 411
         /* check for common upload errors */
412
-        if($image->error = $image->uploadErrors($files["error"])){
412
+        if ($image->error = $image->uploadErrors($files["error"])) {
413 413
             return null;
414 414
         }
415 415
 
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
             return null;
440 440
         }
441 441
 
442
-        if($image->height < 4 || $image->width < 4){
442
+        if ($image->height < 4 || $image->width < 4) {
443 443
             $image->error = $this->error_messages['too_small'];
444 444
             return null;
445 445
         }
446 446
  
447 447
         /* set and get folder name */
448
-        $image->fullPath = $image->location. "/" . $image->name . "." . $image->mime;
448
+        $image->fullPath = $image->location."/".$image->name.".".$image->mime;
449 449
 
450 450
         /* gather image info for json storage */ 
451 451
         $image->serialize = array(
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             }
466 466
         }
467 467
 
468
-        $image->error =  $this->error_messages['unknown'];
468
+        $image->error = $this->error_messages['unknown'];
469 469
         return false;
470 470
     }
471 471
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -41 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * @param array $_files represents the $_FILES array passed as dependency
112 112
      */
113
-    public function __construct(array $_files = [])
114
-    {
113
+    public function __construct(array $_files = []) {
115 114
         $this->_files = $_files;
116 115
     }
117 116
 
@@ -122,8 +121,7 @@  discard block
 block discarded – undo
122 121
      *
123 122
      * @return bool|string
124 123
      */
125
-    protected function getImageMime($tmp_name)
126
-    {
124
+    protected function getImageMime($tmp_name) {
127 125
         if (isset($this->imageMimes[exif_imagetype($tmp_name)])) {
128 126
             return $this->imageMimes [exif_imagetype($tmp_name)];
129 127
         }
@@ -154,8 +152,7 @@  discard block
 block discarded – undo
154 152
      *
155 153
      * @return bool|mixed
156 154
      */
157
-    public function offsetGet($offset)
158
-    {
155
+    public function offsetGet($offset) {
159 156
         if ($offset == "error") {
160 157
             return $this->error;
161 158
         }
@@ -175,8 +172,7 @@  discard block
 block discarded – undo
175 172
      * @param null $isNameProvided
176 173
      * @return $this
177 174
      */
178
-    public function setName($isNameProvided = null)
179
-    {
175
+    public function setName($isNameProvided = null) {
180 176
         if ($isNameProvided) {
181 177
             $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
182 178
         }
@@ -191,8 +187,7 @@  discard block
 block discarded – undo
191 187
      *
192 188
      * @return $this
193 189
      */
194
-    public function setMime(array $fileTypes)
195
-    {
190
+    public function setMime(array $fileTypes) {
196 191
         $this->mimeTypes = $fileTypes;
197 192
         return $this;
198 193
     }
@@ -205,8 +200,7 @@  discard block
 block discarded – undo
205 200
      *
206 201
      * @return $this
207 202
      */
208
-    public function setSize($min, $max)
209
-    {
203
+    public function setSize($min, $max) {
210 204
         $this->size = array($min, $max);
211 205
         return $this;
212 206
     }
@@ -219,8 +213,7 @@  discard block
 block discarded – undo
219 213
      *
220 214
      * @return $this
221 215
      */
222
-    public function setLocation($dir = "bulletproof", $permission = 0666)
223
-    {
216
+    public function setLocation($dir = "bulletproof", $permission = 0666) {
224 217
         if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
225 218
             $createFolder = @mkdir("" . $dir, (int) $permission, true);
226 219
             if (!$createFolder) {
@@ -241,8 +234,7 @@  discard block
 block discarded – undo
241 234
      *
242 235
      * @return $this
243 236
      */
244
-    public function setDimension($maxWidth, $maxHeight)
245
-    {
237
+    public function setDimension($maxWidth, $maxHeight) {
246 238
         $this->dimensions = array($maxWidth, $maxHeight);
247 239
         return $this;
248 240
     }
@@ -254,8 +246,7 @@  discard block
 block discarded – undo
254 246
 	 *
255 247
 	 * @return $this
256 248
 	 */
257
-	public function setErrorMessages($new_error_messages)
258
-	{
249
+	public function setErrorMessages($new_error_messages) {
259 250
 		if($new_array = array_replace_recursive($this->error_messages, $new_error_messages)) {
260 251
 			$this->error_messages = $new_array;
261 252
 		};
@@ -267,8 +258,7 @@  discard block
 block discarded – undo
267 258
      *
268 259
      * @return string
269 260
      */
270
-    public function getName()
271
-    {
261
+    public function getName() {
272 262
         if (!$this->name) {
273 263
            return  uniqid(true) . "_" . str_shuffle(implode(range("e", "q")));
274 264
         }
@@ -281,8 +271,7 @@  discard block
 block discarded – undo
281 271
      *
282 272
      * @return string
283 273
      */
284
-    public function getFullPath()
285
-    {
274
+    public function getFullPath() {
286 275
         $this->fullPath = $this->location . "/" . $this->name . "." . $this->mime;
287 276
         return $this->fullPath;
288 277
     }
@@ -292,8 +281,7 @@  discard block
 block discarded – undo
292 281
      *
293 282
      * @return int
294 283
      */
295
-    public function getSize()
296
-    {
284
+    public function getSize() {
297 285
         return (int) $this->_files["size"];
298 286
     }
299 287
 
@@ -302,8 +290,7 @@  discard block
 block discarded – undo
302 290
      *
303 291
      * @return int
304 292
      */
305
-    public function getHeight()
306
-    {
293
+    public function getHeight() {
307 294
         if ($this->height != null) {
308 295
             return $this->height;
309 296
         }
@@ -317,8 +304,7 @@  discard block
 block discarded – undo
317 304
      *
318 305
      * @return int
319 306
      */
320
-    public function getWidth()
321
-    {
307
+    public function getWidth() {
322 308
         if ($this->width != null) {
323 309
             return $this->width;
324 310
         }
@@ -332,8 +318,7 @@  discard block
 block discarded – undo
332 318
      *
333 319
      * @return string
334 320
      */
335
-    public function getLocation()
336
-    {
321
+    public function getLocation() {
337 322
         if(!$this->location){
338 323
             $this->setLocation(); 
339 324
         }
@@ -346,8 +331,7 @@  discard block
 block discarded – undo
346 331
      *
347 332
      * @return string
348 333
      */
349
-    public function getJson()
350
-    {
334
+    public function getJson() {
351 335
         return json_encode($this->serialize);
352 336
     }
353 337
 
@@ -356,8 +340,7 @@  discard block
 block discarded – undo
356 340
      *
357 341
      * @return string
358 342
      */
359
-    public function getMime()
360
-    {
343
+    public function getMime() {
361 344
         return $this->mime;
362 345
     }
363 346
 
@@ -366,7 +349,7 @@  discard block
 block discarded – undo
366 349
      *
367 350
      * @return string|bool
368 351
      */
369
-    public function getError(){
352
+    public function getError() {
370 353
         return $this->error != "" ? $this->error : false;
371 354
     }
372 355
 
@@ -375,8 +358,7 @@  discard block
 block discarded – undo
375 358
      *
376 359
      * @param $e int error constant
377 360
      */
378
-    protected function uploadErrors($e)
379
-    {
361
+    protected function uploadErrors($e) {
380 362
         $errors = $this->error_messages['upload'];
381 363
         return $errors[$e];
382 364
     }
@@ -387,8 +369,7 @@  discard block
 block discarded – undo
387 369
      * @return bool|Image|null
388 370
      * @throws ImageUploaderException
389 371
      */
390
-    public function upload()
391
-    {
372
+    public function upload() {
392 373
         /* modify variable names for convenience */
393 374
         $image = $this;
394 375
         $files = $this->_files;
@@ -477,8 +458,7 @@  discard block
 block discarded – undo
477 458
      *
478 459
      * @return bool
479 460
      */
480
-    public function moveUploadedFile($tmp_name, $destination)
481
-    {
461
+    public function moveUploadedFile($tmp_name, $destination) {
482 462
         return move_uploaded_file($tmp_name, $destination);
483 463
     }
484 464
 }
Please login to merge, or discard this patch.