Completed
Branch prettify (768db4)
by samayo
01:48
created
src/bulletproof.php 2 patches
Spacing   +14 added lines, -14 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
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
           $image->height < 2 ||
443 443
           $image->width < 2
444 444
         ) {
445
-        $image->error = 'Image height/width should be less than ' . $allowedHeight . '/' . $allowedWidth . ' pixels';
445
+        $image->error = 'Image height/width should be less than '.$allowedHeight.'/'.$allowedWidth.' pixels';
446 446
         return false;
447 447
       }
448 448
 
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
       
142 140
       // return false if $image['key'] isn't found
143 141
       if (!isset($this->_files[$offset])) {
@@ -163,8 +161,7 @@  discard block
 block discarded – undo
163 161
      * 
164 162
      * @return $this
165 163
      */
166
-    public function setDimension($maxWidth, $maxHeight)
167
-    {
164
+    public function setDimension($maxWidth, $maxHeight) {
168 165
       $this->dimensions = array($maxWidth, $maxHeight);
169 166
       return $this;
170 167
     }
@@ -174,8 +171,7 @@  discard block
 block discarded – undo
174 171
      *
175 172
      * @return string
176 173
      */
177
-    public function getFullPath()
178
-    {
174
+    public function getFullPath() {
179 175
       return $this->fullPath = $this->getLocation() . '/' . $this->getName() . '.' . $this->getMime();
180 176
     }
181 177
 
@@ -184,8 +180,7 @@  discard block
 block discarded – undo
184 180
      *
185 181
      * @return int
186 182
      */
187
-    public function getSize()
188
-    {
183
+    public function getSize() {
189 184
       return (int) $this->_files['size'];
190 185
     }
191 186
 
@@ -197,8 +192,7 @@  discard block
 block discarded – undo
197 192
      *
198 193
      * @return $this
199 194
      */
200
-    public function setSize($min, $max)
201
-    {
195
+    public function setSize($min, $max) {
202 196
       $this->size = array($min, $max);
203 197
       return $this;
204 198
     }
@@ -208,8 +202,7 @@  discard block
 block discarded – undo
208 202
      *
209 203
      * @return string
210 204
      */
211
-    public function getJson()
212
-    {
205
+    public function getJson() {
213 206
       return json_encode (
214 207
         array(
215 208
           'name'      => $this->name,
@@ -228,8 +221,7 @@  discard block
 block discarded – undo
228 221
      *
229 222
      * @return null|string
230 223
      */
231
-    public function getMime()
232
-    {
224
+    public function getMime() {
233 225
       if(!$this->mime){
234 226
         $this->mime = $this->getImageMime($this->_files['tmp_name']);
235 227
       }
@@ -244,8 +236,7 @@  discard block
 block discarded – undo
244 236
      * 
245 237
      * @return $this
246 238
      */
247
-    public function setMime(array $fileTypes)
248
-    {
239
+    public function setMime(array $fileTypes) {
249 240
       $this->mimeTypes = $fileTypes;
250 241
       return $this;
251 242
     }
@@ -257,8 +248,7 @@  discard block
 block discarded – undo
257 248
      * 
258 249
      * @return null|string
259 250
      */
260
-    protected function getImageMime($tmp_name)
261
-    {
251
+    protected function getImageMime($tmp_name) {
262 252
       $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)];
263 253
       if (!$this->mime) {
264 254
         return null;
@@ -272,8 +262,7 @@  discard block
 block discarded – undo
272 262
      *
273 263
      * @return string|false
274 264
      */
275
-    public function getError()
276
-    {
265
+    public function getError() {
277 266
       return $this->error;
278 267
     }
279 268
 
@@ -282,8 +271,7 @@  discard block
 block discarded – undo
282 271
      *
283 272
      * @return string
284 273
      */
285
-    public function getName()
286
-    {
274
+    public function getName() {
287 275
       if (!$this->name) {
288 276
         $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
289 277
       }
@@ -297,8 +285,7 @@  discard block
 block discarded – undo
297 285
      * @param null $isNameProvided
298 286
      * @return $this
299 287
      */
300
-    public function setName($isNameProvided = null)
301
-    {
288
+    public function setName($isNameProvided = null) {
302 289
       if ($isNameProvided) {
303 290
         $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
304 291
       }
@@ -311,8 +298,7 @@  discard block
 block discarded – undo
311 298
      *
312 299
      * @return int
313 300
      */
314
-    public function getWidth()
315
-    {
301
+    public function getWidth() {
316 302
       if ($this->width != null) {
317 303
         return $this->width;
318 304
       }
@@ -326,8 +312,7 @@  discard block
 block discarded – undo
326 312
      *
327 313
      * @return int
328 314
      */
329
-    public function getHeight()
330
-    {
315
+    public function getHeight() {
331 316
       if ($this->height != null) {
332 317
         return $this->height;
333 318
       }
@@ -341,8 +326,7 @@  discard block
 block discarded – undo
341 326
      *
342 327
      * @return string
343 328
      */
344
-    public function getLocation()
345
-    {
329
+    public function getLocation() {
346 330
       if (!$this->location) {
347 331
         $this->setLocation();
348 332
       }
@@ -356,8 +340,7 @@  discard block
 block discarded – undo
356 340
      * @param $dir string the folder name to check
357 341
      * @return bool
358 342
      */
359
-    private function isDirectoryValid($dir) 
360
-    {
343
+    private function isDirectoryValid($dir) {
361 344
       return !file_exists($dir) && !is_dir($dir) || is_writable($dir); 
362 345
     }
363 346
 
@@ -368,8 +351,7 @@  discard block
 block discarded – undo
368 351
      * @param int $permission chmod permission
369 352
      * @return $this
370 353
      */
371
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
372
-    {
354
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
373 355
       $isDirectoryValid = $this->isDirectoryValid($dir); 
374 356
 
375 357
       if(!$isDirectoryValid){
@@ -394,8 +376,7 @@  discard block
 block discarded – undo
394 376
      * 
395 377
      * @return false|null|Image
396 378
      */
397
-    public function upload()
398
-    {
379
+    public function upload() {
399 380
       $image = $this;
400 381
       $files = $this->_files;
401 382
 
@@ -457,8 +438,7 @@  discard block
 block discarded – undo
457 438
      *
458 439
      * @return bool
459 440
      */
460
-    protected function isSaved($tmp_name, $destination)
461
-    {
441
+    protected function isSaved($tmp_name, $destination) {
462 442
       return move_uploaded_file($tmp_name, $destination);
463 443
     }
464 444
 }
465 445
\ No newline at end of file
Please login to merge, or discard this patch.