Completed
Branch prettify (847d68)
by samayo
01:21
created
src/bulletproof.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
      * @param mixed $value
111 111
      * @return null
112 112
      */
113
-    public function offsetSet($offset, $value){}
113
+    public function offsetSet($offset, $value) {}
114 114
 
115 115
     /**
116 116
      * @param mixed $offset
117 117
      * @return null
118 118
      */
119
-    public function offsetExists($offset){}
119
+    public function offsetExists($offset) {}
120 120
 
121 121
     /**
122 122
      * @param mixed $offset
123 123
      * @return null
124 124
      */
125
-    public function offsetUnset($offset){}
125
+    public function offsetUnset($offset) {}
126 126
 
127 127
     /**
128 128
      * Gets array value \ArrayAccess
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $this->_files = $this->_files[$offset];
147 147
 
148 148
         // check for common upload errors
149
-        if(isset($this->_files['error'])){
149
+        if (isset($this->_files['error'])) {
150 150
             $this->error = $this->commonUploadErrors[$this->_files['error']];
151 151
         }
152 152
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getFullPath()
176 176
     {
177
-        $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime;
177
+        $this->fullPath = $this->location.'/'.$this->name.'.'.$this->mime;
178 178
         return $this->fullPath;
179 179
     }
180 180
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     public function getJson()
211 211
     {
212 212
         /* gather image info for json storage */
213
-        return json_encode (
213
+        return json_encode(
214 214
             array(
215 215
                 'name'      => $this->name,
216 216
                 'mime'      => $this->mime,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     public function getName()
286 286
     {
287 287
         if (!$this->name) {
288
-            return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
288
+            return uniqid('', true).'_'.str_shuffle(implode(range('e', 'q')));
289 289
         }
290 290
 
291 291
         return $this->name;
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
     public function setLocation($dir = 'bulletproof', $permission = 0666)
362 362
     {
363 363
         if (!file_exists($dir) && !is_dir($dir)) {
364
-            $createFolder = @mkdir('' . $dir, (int) $permission, true);
364
+            $createFolder = @mkdir(''.$dir, (int) $permission, true);
365 365
             if (!$createFolder) {
366
-                $this->error = 'Error! Folder ' . $dir . ' could not be created';
366
+                $this->error = 'Error! Folder '.$dir.' could not be created';
367 367
                 return false;
368 368
             }
369 369
         }
370 370
 
371 371
         /* check if we can create a file in the directory */
372 372
         if (!is_writable($dir)) {
373
-            $this->error = 'The images directory \'' . $dir . '\' is not writable!';
373
+            $this->error = 'The images directory \''.$dir.'\' is not writable!';
374 374
             return false;
375 375
         }
376 376
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
         if ($files['size'] < $minSize || $files['size'] > $maxSize) {
417 417
             $min = intval($minSize / 1000) ?: 1;
418 418
             $max = intval($maxSize / 1000) ?: 1;
419
-            $image->error = 'Image size should be at least ' . $min . ' KB, and no more than ' . $max . ' KB';
419
+            $image->error = 'Image size should be at least '.$min.' KB, and no more than '.$max.' KB';
420 420
             return false;
421 421
         }
422 422
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
         list($allowedWidth, $allowedHeight) = $image->dimensions;
425 425
 
426 426
         if ($image->height > $allowedHeight || $image->width > $allowedWidth) {
427
-            $image->error = 'Image height/width should be less than ' . $allowedHeight . '/' . $allowedWidth . ' pixels';
427
+            $image->error = 'Image height/width should be less than '.$allowedHeight.'/'.$allowedWidth.' pixels';
428 428
             return false;
429 429
         }
430 430
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -38 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * @param array $_files represents the $_FILES array passed as dependency
96 96
      */
97
-    public function __construct(array $_files = array())
98
-    {
97
+    public function __construct(array $_files = array()) {
99 98
         /* check if php_exif is enabled */
100 99
         if (!function_exists('exif_imagetype')) {
101 100
             $this->error = 'Function \'exif_imagetype\' Not found. Please enable \'php_exif\' in your PHP.ini';
@@ -131,8 +130,7 @@  discard block
 block discarded – undo
131 130
      *
132 131
      * @return string|boolean
133 132
      */
134
-    public function offsetGet($offset)
135
-    {   
133
+    public function offsetGet($offset) {
136 134
         // return error if requested
137 135
         if ($offset == 'error') {
138 136
             return $this->error;
@@ -161,8 +159,7 @@  discard block
 block discarded – undo
161 159
      *
162 160
      * @return $this
163 161
      */
164
-    public function setDimension($maxWidth, $maxHeight)
165
-    {
162
+    public function setDimension($maxWidth, $maxHeight) {
166 163
         $this->dimensions = array($maxWidth, $maxHeight);
167 164
         return $this;
168 165
     }
@@ -172,8 +169,7 @@  discard block
 block discarded – undo
172 169
      *
173 170
      * @return string
174 171
      */
175
-    public function getFullPath()
176
-    {
172
+    public function getFullPath() {
177 173
         $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime;
178 174
         return $this->fullPath;
179 175
     }
@@ -183,8 +179,7 @@  discard block
 block discarded – undo
183 179
      *
184 180
      * @return int
185 181
      */
186
-    public function getSize()
187
-    {
182
+    public function getSize() {
188 183
         return (int) $this->_files['size'];
189 184
     }
190 185
 
@@ -196,8 +191,7 @@  discard block
 block discarded – undo
196 191
      *
197 192
      * @return $this
198 193
      */
199
-    public function setSize($min, $max)
200
-    {
194
+    public function setSize($min, $max) {
201 195
         $this->size = array($min, $max);
202 196
         return $this;
203 197
     }
@@ -207,8 +201,7 @@  discard block
 block discarded – undo
207 201
      *
208 202
      * @return string
209 203
      */
210
-    public function getJson()
211
-    {
204
+    public function getJson() {
212 205
         /* gather image info for json storage */
213 206
         return json_encode (
214 207
             array(
@@ -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
             return $this->getImageMime($this->_files['tmp_name']);
235 227
         }
@@ -243,8 +235,7 @@  discard block
 block discarded – undo
243 235
      *
244 236
      * @return $this
245 237
      */
246
-    public function setMime(array $fileTypes)
247
-    {
238
+    public function setMime(array $fileTypes) {
248 239
         $this->mimeTypes = $fileTypes;
249 240
         return $this;
250 241
     }
@@ -256,8 +247,7 @@  discard block
 block discarded – undo
256 247
      *
257 248
      * @return null|string
258 249
      */
259
-    protected function getImageMime($tmp_name)
260
-    {
250
+    protected function getImageMime($tmp_name) {
261 251
         $mime = @ $this->acceptedMimes[exif_imagetype($tmp_name)];
262 252
 
263 253
         if (!$mime) {
@@ -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 != '' ? $this->error : false;
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
             return 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
         }
@@ -358,8 +342,7 @@  discard block
 block discarded – undo
358 342
      *
359 343
      * @return $this
360 344
      */
361
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
362
-    {
345
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
363 346
         if (!file_exists($dir) && !is_dir($dir)) {
364 347
             $createFolder = @mkdir('' . $dir, (int) $permission, true);
365 348
             if (!$createFolder) {
@@ -382,8 +365,7 @@  discard block
 block discarded – undo
382 365
      * This methods validates and uploads the image
383 366
      * @return false|Image
384 367
      */
385
-    public function upload()
386
-    {
368
+    public function upload() {
387 369
         /* modify variable names for convenience */
388 370
         $image = $this;
389 371
         $files = $this->_files;
@@ -453,8 +435,7 @@  discard block
 block discarded – undo
453 435
      *
454 436
      * @return bool
455 437
      */
456
-    public function moveUploadedFile($tmp_name, $destination)
457
-    {
438
+    public function moveUploadedFile($tmp_name, $destination) {
458 439
         return move_uploaded_file($tmp_name, $destination);
459 440
     }
460 441
 }
461 442
\ No newline at end of file
Please login to merge, or discard this patch.