Completed
Branch prettify (768db4)
by samayo
01:48
created
src/bulletproof.php 1 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.