Completed
Branch prettify (10ca43)
by samayo
07:09
created
src/bulletproof.php 1 patch
Braces   +20 added lines, -40 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
        return $this->fullPath = $this->getLocation() . '/' . $this->getName() . '.' . $this->getMime();
178 174
     }
179 175
 
@@ -182,8 +178,7 @@  discard block
 block discarded – undo
182 178
      *
183 179
      * @return int
184 180
      */
185
-    public function getSize()
186
-    {
181
+    public function getSize() {
187 182
         return (int) $this->_files['size'];
188 183
     }
189 184
 
@@ -195,8 +190,7 @@  discard block
 block discarded – undo
195 190
      *
196 191
      * @return $this
197 192
      */
198
-    public function setSize($min, $max)
199
-    {
193
+    public function setSize($min, $max) {
200 194
         $this->size = array($min, $max);
201 195
         return $this;
202 196
     }
@@ -206,8 +200,7 @@  discard block
 block discarded – undo
206 200
      *
207 201
      * @return string
208 202
      */
209
-    public function getJson()
210
-    {
203
+    public function getJson() {
211 204
         /* gather image info for json storage */
212 205
         return json_encode (
213 206
             array(
@@ -227,8 +220,7 @@  discard block
 block discarded – undo
227 220
      *
228 221
      * @return null|string
229 222
      */
230
-    public function getMime()
231
-    {
223
+    public function getMime() {
232 224
         if (!$this->mime) {
233 225
             return $this->getImageMime($this->_files['tmp_name']);
234 226
         }
@@ -242,8 +234,7 @@  discard block
 block discarded – undo
242 234
      *
243 235
      * @return $this
244 236
      */
245
-    public function setMime(array $fileTypes)
246
-    {
237
+    public function setMime(array $fileTypes) {
247 238
         $this->mimeTypes = $fileTypes;
248 239
         return $this;
249 240
     }
@@ -255,8 +246,7 @@  discard block
 block discarded – undo
255 246
      *
256 247
      * @return null|string
257 248
      */
258
-    protected function getImageMime($tmp_name)
259
-    {
249
+    protected function getImageMime($tmp_name) {
260 250
         $mime = @ $this->acceptedMimes[exif_imagetype($tmp_name)];
261 251
 
262 252
         if (!$mime) {
@@ -271,8 +261,7 @@  discard block
 block discarded – undo
271 261
      *
272 262
      * @return string|false
273 263
      */
274
-    public function getError()
275
-    {
264
+    public function getError() {
276 265
         return $this->error != '' ? $this->error : false;
277 266
     }
278 267
 
@@ -281,8 +270,7 @@  discard block
 block discarded – undo
281 270
      *
282 271
      * @return string
283 272
      */
284
-    public function getName()
285
-    {
273
+    public function getName() {
286 274
         if (!$this->name) {
287 275
             return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
288 276
         }
@@ -296,8 +284,7 @@  discard block
 block discarded – undo
296 284
      * @param null $isNameProvided
297 285
      * @return $this
298 286
      */
299
-    public function setName($isNameProvided = null)
300
-    {
287
+    public function setName($isNameProvided = null) {
301 288
         if ($isNameProvided) {
302 289
             $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING);
303 290
         }
@@ -310,8 +297,7 @@  discard block
 block discarded – undo
310 297
      *
311 298
      * @return int
312 299
      */
313
-    public function getWidth()
314
-    {
300
+    public function getWidth() {
315 301
         if ($this->width != null) {
316 302
             return $this->width;
317 303
         }
@@ -325,8 +311,7 @@  discard block
 block discarded – undo
325 311
      *
326 312
      * @return int
327 313
      */
328
-    public function getHeight()
329
-    {
314
+    public function getHeight() {
330 315
         if ($this->height != null) {
331 316
             return $this->height;
332 317
         }
@@ -340,8 +325,7 @@  discard block
 block discarded – undo
340 325
      *
341 326
      * @return string
342 327
      */
343
-    public function getLocation()
344
-    {
328
+    public function getLocation() {
345 329
         if (!$this->location) {
346 330
             $this->setLocation();
347 331
         }
@@ -356,8 +340,7 @@  discard block
 block discarded – undo
356 340
      * 
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
 
@@ -369,8 +352,7 @@  discard block
 block discarded – undo
369 352
      *
370 353
      * @return $this
371 354
      */
372
-    public function setLocation($dir = 'bulletproof', $permission = 0666)
373
-    {
355
+    public function setLocation($dir = 'bulletproof', $permission = 0666) {
374 356
         $isDirectoryValid = $this->isDirectoryValid($dir); 
375 357
 
376 358
         if(!$isDirectoryValid){
@@ -393,8 +375,7 @@  discard block
 block discarded – undo
393 375
      * This methods validates and uploads the image
394 376
      * @return false|Image
395 377
      */
396
-    public function upload()
397
-    {
378
+    public function upload() {
398 379
         /* modify variable names for convenience */
399 380
         $image = $this;
400 381
         $files = $this->_files;
@@ -463,8 +444,7 @@  discard block
 block discarded – undo
463 444
      *
464 445
      * @return bool
465 446
      */
466
-    public function moveUploadedFile($tmp_name, $destination)
467
-    {
447
+    public function moveUploadedFile($tmp_name, $destination) {
468 448
         return move_uploaded_file($tmp_name, $destination);
469 449
     }
470 450
 }
471 451
\ No newline at end of file
Please login to merge, or discard this patch.