Completed
Branch prettify (59eb21)
by samayo
01:42
created
src/bulletproof.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
      * 
115 115
      * @return null
116 116
      */
117
-    public function offsetSet($offset, $value){}
117
+    public function offsetSet($offset, $value) {}
118 118
 
119 119
     /**
120 120
      * @param mixed $offset
121 121
      * 
122 122
      * @return null
123 123
      */
124
-    public function offsetExists($offset){}
124
+    public function offsetExists($offset) {}
125 125
 
126 126
     /**
127 127
      * @param mixed $offset
128 128
      * 
129 129
      * @return null
130 130
      */
131
-    public function offsetUnset($offset){}
131
+    public function offsetUnset($offset) {}
132 132
 
133 133
     /**
134 134
      * Gets array value \ArrayAccess
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
       $this->_files = $this->_files[$offset];
153 153
 
154 154
       // check for common upload errors
155
-      if(isset($this->_files['error'])){
155
+      if (isset($this->_files['error'])) {
156 156
           $this->error = $this->commonUploadErrors[$this->_files['error']];
157 157
       }
158 158
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getFullPath()
182 182
     {
183
-      return $this->fullPath = $this->getLocation() . '/' . $this->getName() . '.' . $this->getMime();
183
+      return $this->fullPath = $this->getLocation().'/'.$this->getName().'.'.$this->getMime();
184 184
     }
185 185
 
186 186
     /**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     public function getJson()
216 216
     {
217
-      return json_encode (
217
+      return json_encode(
218 218
         array(
219 219
           'name'      => $this->name,
220 220
           'mime'      => $this->mime,
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function getMime()
236 236
     {
237
-      if(!$this->mime){
237
+      if (!$this->mime) {
238 238
         $this->mime = $this->getImageMime($this->_files['tmp_name']);
239 239
       }
240 240
       
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     public function getName()
290 290
     {
291 291
       if (!$this->name) {
292
-        $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
292
+        $this->name = uniqid('', true).'_'.str_shuffle(implode(range('e', 'q')));
293 293
       }
294 294
 
295 295
       return $this->name;
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
     {
377 377
       $isDirectoryValid = $this->isDirectoryValid($dir); 
378 378
 
379
-      if(!$isDirectoryValid){
380
-        $this->error = 'Can not create a directory  \'' . $dir . '\', please check your dir permission';
379
+      if (!$isDirectoryValid) {
380
+        $this->error = 'Can not create a directory  \''.$dir.'\', please check your dir permission';
381 381
         return false;
382 382
       }
383 383
     
384
-      $create = !is_dir($dir) ? @mkdir('' . $dir, (int) $permission, true) : true; 
384
+      $create = !is_dir($dir) ? @mkdir(''.$dir, (int) $permission, true) : true; 
385 385
 
386 386
       if (!$create) {
387
-        $this->error = 'Error! directory \'' . $dir . '\' could not be created';
387
+        $this->error = 'Error! directory \''.$dir.'\' could not be created';
388 388
         return false;
389 389
       }
390 390
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
       if ($files['size'] < $minSize || $files['size'] > $maxSize) {
430 430
         $min = intval($minSize / 1000) ?: 1;
431 431
         $max = intval($maxSize / 1000) ?: 1;
432
-        $image->error = 'Image size should be at least ' . $min . ' KB, and no more than ' . $max . ' KB';
432
+        $image->error = 'Image size should be at least '.$min.' KB, and no more than '.$max.' KB';
433 433
         return false;
434 434
       }
435 435
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
       list($allowedWidth, $allowedHeight) = $image->dimensions;
438 438
 
439 439
       if ($image->height > $allowedHeight || $image->width > $allowedWidth) {
440
-        $image->error = 'Image height/width should be less than ' . $allowedHeight . '/' . $allowedWidth . ' pixels';
440
+        $image->error = 'Image height/width should be less than '.$allowedHeight.'/'.$allowedWidth.' pixels';
441 441
         return false;
442 442
       }
443 443
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     public function moveUploadedFile($tmp_name, $destination)
462 462
     {
463 463
       if ($image->error === '') {
464
-        $moveUpload = move_uploaded_file($tmp_name, $destination);;
464
+        $moveUpload = move_uploaded_file($tmp_name, $destination); ;
465 465
         if (false !== $moveUpload) {
466 466
           return $this;
467 467
         } else {
Please login to merge, or discard this patch.
Braces   +20 added lines, -40 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * @param array $_files represents the $_FILES array passed as dependency
100 100
      */
101
-    public function __construct(array $_files = array())
102
-    {
101
+    public function __construct(array $_files = array()) {
103 102
       /* check if php_exif is enabled */
104 103
       if (!function_exists('exif_imagetype')) {
105 104
           $this->error = 'Function \'exif_imagetype\' Not found. Please enable \'php_exif\' in your php.ini';
@@ -136,8 +135,7 @@  discard block
 block discarded – undo
136 135
      * @param mixed $offset
137 136
      * @return string|boolean
138 137
      */
139
-    public function offsetGet($offset)
140
-    {   
138
+    public function offsetGet($offset) {
141 139
       // return error if requested
142 140
       if ($offset == 'error') {
143 141
           return $this->error;
@@ -167,8 +165,7 @@  discard block
 block discarded – undo
167 165
      * 
168 166
      * @return $this
169 167
      */
170
-    public function setDimension($maxWidth, $maxHeight)
171
-    {
168
+    public function setDimension($maxWidth, $maxHeight) {
172 169
       $this->dimensions = array($maxWidth, $maxHeight);
173 170
       return $this;
174 171
     }
@@ -178,8 +175,7 @@  discard block
 block discarded – undo
178 175
      *
179 176
      * @return string
180 177
      */
181
-    public function getFullPath()
182
-    {
178
+    public function getFullPath() {
183 179
       return $this->fullPath = $this->getLocation() . '/' . $this->getName() . '.' . $this->getMime();
184 180
     }
185 181
 
@@ -188,8 +184,7 @@  discard block
 block discarded – undo
188 184
      *
189 185
      * @return int
190 186
      */
191
-    public function getSize()
192
-    {
187
+    public function getSize() {
193 188
       return (int) $this->_files['size'];
194 189
     }
195 190
 
@@ -201,8 +196,7 @@  discard block
 block discarded – undo
201 196
      *
202 197
      * @return $this
203 198
      */
204
-    public function setSize($min, $max)
205
-    {
199
+    public function setSize($min, $max) {
206 200
       $this->size = array($min, $max);
207 201
       return $this;
208 202
     }
@@ -212,8 +206,7 @@  discard block
 block discarded – undo
212 206
      *
213 207
      * @return string
214 208
      */
215
-    public function getJson()
216
-    {
209
+    public function getJson() {
217 210
       return json_encode (
218 211
         array(
219 212
           'name'      => $this->name,
@@ -232,8 +225,7 @@  discard block
 block discarded – undo
232 225
      *
233 226
      * @return null|string
234 227
      */
235
-    public function getMime()
236
-    {
228
+    public function getMime() {
237 229
       if(!$this->mime){
238 230
         $this->mime = $this->getImageMime($this->_files['tmp_name']);
239 231
       }
@@ -248,8 +240,7 @@  discard block
 block discarded – undo
248 240
      * 
249 241
      * @return $this
250 242
      */
251
-    public function setMime(array $fileTypes)
252
-    {
243
+    public function setMime(array $fileTypes) {
253 244
       $this->mimeTypes = $fileTypes;
254 245
       return $this;
255 246
     }
@@ -261,8 +252,7 @@  discard block
 block discarded – undo
261 252
      * 
262 253
      * @return null|string
263 254
      */
264
-    protected function getImageMime($tmp_name)
265
-    {
255
+    protected function getImageMime($tmp_name) {
266 256
       $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)];
267 257
       if (!$this->mime) {
268 258
         return null;
@@ -276,8 +266,7 @@  discard block
 block discarded – undo
276 266
      *
277 267
      * @return string|false
278 268
      */
279
-    public function getError()
280
-    {
269
+    public function getError() {
281 270
       return $this->error;
282 271
     }
283 272
 
@@ -286,8 +275,7 @@  discard block
 block discarded – undo
286 275
      *
287 276
      * @return string
288 277
      */
289
-    public function getName()
290
-    {
278
+    public function getName() {
291 279
       if (!$this->name) {
292 280
         $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
293 281
       }
@@ -301,8 +289,7 @@  discard block
 block discarded – undo
301 289
      * @param null $isNameProvided
302 290
      * @return $this
303 291
      */
304
-    public function setName($isNameProvided = null)
305
-    {
292
+    public function setName($isNameProvided = null) {
306 293
       if ($isNameProvided) {
307 294
         $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
308 295
       }
@@ -315,8 +302,7 @@  discard block
 block discarded – undo
315 302
      *
316 303
      * @return int
317 304
      */
318
-    public function getWidth()
319
-    {
305
+    public function getWidth() {
320 306
       if ($this->width != null) {
321 307
         return $this->width;
322 308
       }
@@ -330,8 +316,7 @@  discard block
 block discarded – undo
330 316
      *
331 317
      * @return int
332 318
      */
333
-    public function getHeight()
334
-    {
319
+    public function getHeight() {
335 320
       if ($this->height != null) {
336 321
         return $this->height;
337 322
       }
@@ -345,8 +330,7 @@  discard block
 block discarded – undo
345 330
      *
346 331
      * @return string
347 332
      */
348
-    public function getLocation()
349
-    {
333
+    public function getLocation() {
350 334
       if (!$this->location) {
351 335
         $this->setLocation();
352 336
       }
@@ -360,8 +344,7 @@  discard block
 block discarded – undo
360 344
      * @param $dir string the folder name to check
361 345
      * @return bool
362 346
      */
363
-    private function isDirectoryValid($dir) 
364
-    {
347
+    private function isDirectoryValid($dir) {
365 348
       return !file_exists($dir) && !is_dir($dir) || is_writable($dir); 
366 349
     }
367 350
 
@@ -372,8 +355,7 @@  discard block
 block discarded – undo
372 355
      * @param int $permission chmod permission
373 356
      * @return $this
374 357
      */
375
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
376
-    {
358
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
377 359
       $isDirectoryValid = $this->isDirectoryValid($dir); 
378 360
 
379 361
       if(!$isDirectoryValid){
@@ -397,8 +379,7 @@  discard block
 block discarded – undo
397 379
      * 
398 380
      * @return false|Image
399 381
      */
400
-    public function upload()
401
-    {
382
+    public function upload() {
402 383
       $image = $this;
403 384
       $files = $this->_files;
404 385
 
@@ -458,8 +439,7 @@  discard block
 block discarded – undo
458 439
      *
459 440
      * @return bool
460 441
      */
461
-    public function moveUploadedFile($tmp_name, $destination)
462
-    {
442
+    public function moveUploadedFile($tmp_name, $destination) {
463 443
       if ($image->error === '') {
464 444
         $moveUpload = move_uploaded_file($tmp_name, $destination);;
465 445
         if (false !== $moveUpload) {
Please login to merge, or discard this patch.