@@ -99,8 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @param array $_files represents the $_FILES array passed as dependency |
| 101 | 101 | */ |
| 102 | - public function __construct(array $_files = array()) |
|
| 103 | - {
|
|
| 102 | + public function __construct(array $_files = array()) { |
|
| 104 | 103 | /* check if php_exif is enabled */ |
| 105 | 104 | if (!function_exists('exif_imagetype')) {
|
| 106 | 105 | $this->error = 'Function \'exif_imagetype\' Not found. Please enable \'php_exif\' in your PHP.ini'; |
@@ -114,23 +113,20 @@ discard block |
||
| 114 | 113 | * @param mixed $offset |
| 115 | 114 | * @param mixed $value |
| 116 | 115 | */ |
| 117 | - public function offsetSet($offset, $value) |
|
| 118 | - {
|
|
| 116 | + public function offsetSet($offset, $value) { |
|
| 119 | 117 | } |
| 120 | 118 | |
| 121 | 119 | /** |
| 122 | 120 | * @param mixed $offset |
| 123 | 121 | * @return null |
| 124 | 122 | */ |
| 125 | - public function offsetExists($offset) |
|
| 126 | - {
|
|
| 123 | + public function offsetExists($offset) { |
|
| 127 | 124 | } |
| 128 | 125 | |
| 129 | 126 | /** |
| 130 | 127 | * @param mixed $offset |
| 131 | 128 | */ |
| 132 | - public function offsetUnset($offset) |
|
| 133 | - {
|
|
| 129 | + public function offsetUnset($offset) { |
|
| 134 | 130 | } |
| 135 | 131 | |
| 136 | 132 | /** |
@@ -140,8 +136,7 @@ discard block |
||
| 140 | 136 | * |
| 141 | 137 | * @return string|boolean |
| 142 | 138 | */ |
| 143 | - public function offsetGet($offset) |
|
| 144 | - {
|
|
| 139 | + public function offsetGet($offset) { |
|
| 145 | 140 | /* return error if requested */ |
| 146 | 141 | if ($offset == 'error') {
|
| 147 | 142 | return $this->error; |
@@ -169,8 +164,7 @@ discard block |
||
| 169 | 164 | * |
| 170 | 165 | * @return string |
| 171 | 166 | */ |
| 172 | - protected function commonUploadErrors($errors) |
|
| 173 | - {
|
|
| 167 | + protected function commonUploadErrors($errors) { |
|
| 174 | 168 | return $this->common_upload_errors[$errors]; |
| 175 | 169 | } |
| 176 | 170 | |
@@ -182,8 +176,7 @@ discard block |
||
| 182 | 176 | * |
| 183 | 177 | * @return $this |
| 184 | 178 | */ |
| 185 | - public function setDimension($maxWidth, $maxHeight) |
|
| 186 | - {
|
|
| 179 | + public function setDimension($maxWidth, $maxHeight) { |
|
| 187 | 180 | $this->dimensions = array($maxWidth, $maxHeight); |
| 188 | 181 | return $this; |
| 189 | 182 | } |
@@ -193,8 +186,7 @@ discard block |
||
| 193 | 186 | * |
| 194 | 187 | * @return string |
| 195 | 188 | */ |
| 196 | - public function getFullPath() |
|
| 197 | - {
|
|
| 189 | + public function getFullPath() { |
|
| 198 | 190 | $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime; |
| 199 | 191 | return $this->fullPath; |
| 200 | 192 | } |
@@ -204,8 +196,7 @@ discard block |
||
| 204 | 196 | * |
| 205 | 197 | * @return int |
| 206 | 198 | */ |
| 207 | - public function getSize() |
|
| 208 | - {
|
|
| 199 | + public function getSize() { |
|
| 209 | 200 | return (int)$this->_files['size']; |
| 210 | 201 | } |
| 211 | 202 | |
@@ -217,8 +208,7 @@ discard block |
||
| 217 | 208 | * |
| 218 | 209 | * @return $this |
| 219 | 210 | */ |
| 220 | - public function setSize($min, $max) |
|
| 221 | - {
|
|
| 211 | + public function setSize($min, $max) { |
|
| 222 | 212 | $this->size = array($min, $max); |
| 223 | 213 | return $this; |
| 224 | 214 | } |
@@ -228,8 +218,7 @@ discard block |
||
| 228 | 218 | * |
| 229 | 219 | * @return string |
| 230 | 220 | */ |
| 231 | - public function getJson() |
|
| 232 | - {
|
|
| 221 | + public function getJson() { |
|
| 233 | 222 | return json_encode($this->serialize); |
| 234 | 223 | } |
| 235 | 224 | |
@@ -238,8 +227,7 @@ discard block |
||
| 238 | 227 | * |
| 239 | 228 | * @return null|string |
| 240 | 229 | */ |
| 241 | - public function getMime() |
|
| 242 | - {
|
|
| 230 | + public function getMime() { |
|
| 243 | 231 | if (!$this->mime) {
|
| 244 | 232 | return $this->getImageMime($this->_files['tmp_name']); |
| 245 | 233 | } |
@@ -253,8 +241,7 @@ discard block |
||
| 253 | 241 | * |
| 254 | 242 | * @return $this |
| 255 | 243 | */ |
| 256 | - public function setMime(array $fileTypes) |
|
| 257 | - {
|
|
| 244 | + public function setMime(array $fileTypes) { |
|
| 258 | 245 | $this->mimeTypes = $fileTypes; |
| 259 | 246 | return $this; |
| 260 | 247 | } |
@@ -266,8 +253,7 @@ discard block |
||
| 266 | 253 | * |
| 267 | 254 | * @return null|string |
| 268 | 255 | */ |
| 269 | - protected function getImageMime($tmp_name) |
|
| 270 | - {
|
|
| 256 | + protected function getImageMime($tmp_name) { |
|
| 271 | 257 | $mime = @$this->imageMimes[exif_imagetype($tmp_name)]; |
| 272 | 258 | |
| 273 | 259 | if (!$mime) {
|
@@ -282,8 +268,7 @@ discard block |
||
| 282 | 268 | * |
| 283 | 269 | * @return string|false |
| 284 | 270 | */ |
| 285 | - public function getError() |
|
| 286 | - {
|
|
| 271 | + public function getError() { |
|
| 287 | 272 | return $this->error != '' ? $this->error : false; |
| 288 | 273 | } |
| 289 | 274 | |
@@ -291,8 +276,7 @@ discard block |
||
| 291 | 276 | * This methods validates and uploads the image |
| 292 | 277 | * @return false|Image |
| 293 | 278 | */ |
| 294 | - public function upload() |
|
| 295 | - {
|
|
| 279 | + public function upload() { |
|
| 296 | 280 | /* modify variable names for convenience */ |
| 297 | 281 | $image = $this; |
| 298 | 282 | $files = $this->_files; |
@@ -370,8 +354,7 @@ discard block |
||
| 370 | 354 | * |
| 371 | 355 | * @return string |
| 372 | 356 | */ |
| 373 | - public function getName() |
|
| 374 | - {
|
|
| 357 | + public function getName() { |
|
| 375 | 358 | if (!$this->name) {
|
| 376 | 359 | return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
|
| 377 | 360 | } |
@@ -385,8 +368,7 @@ discard block |
||
| 385 | 368 | * @param null $isNameProvided |
| 386 | 369 | * @return $this |
| 387 | 370 | */ |
| 388 | - public function setName($isNameProvided = null) |
|
| 389 | - {
|
|
| 371 | + public function setName($isNameProvided = null) { |
|
| 390 | 372 | if ($isNameProvided) {
|
| 391 | 373 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
| 392 | 374 | } |
@@ -399,8 +381,7 @@ discard block |
||
| 399 | 381 | * |
| 400 | 382 | * @return int |
| 401 | 383 | */ |
| 402 | - public function getWidth() |
|
| 403 | - {
|
|
| 384 | + public function getWidth() { |
|
| 404 | 385 | if ($this->width != null) {
|
| 405 | 386 | return $this->width; |
| 406 | 387 | } |
@@ -414,8 +395,7 @@ discard block |
||
| 414 | 395 | * |
| 415 | 396 | * @return int |
| 416 | 397 | */ |
| 417 | - public function getHeight() |
|
| 418 | - {
|
|
| 398 | + public function getHeight() { |
|
| 419 | 399 | if ($this->height != null) {
|
| 420 | 400 | return $this->height; |
| 421 | 401 | } |
@@ -429,8 +409,7 @@ discard block |
||
| 429 | 409 | * |
| 430 | 410 | * @return string |
| 431 | 411 | */ |
| 432 | - public function getLocation() |
|
| 433 | - {
|
|
| 412 | + public function getLocation() { |
|
| 434 | 413 | if (!$this->location) {
|
| 435 | 414 | $this->setLocation(); |
| 436 | 415 | } |
@@ -446,8 +425,7 @@ discard block |
||
| 446 | 425 | * |
| 447 | 426 | * @return $this |
| 448 | 427 | */ |
| 449 | - public function setLocation($dir = 'bulletproof', $permission = 0666) |
|
| 450 | - {
|
|
| 428 | + public function setLocation($dir = 'bulletproof', $permission = 0666) { |
|
| 451 | 429 | |
| 452 | 430 | if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
|
| 453 | 431 | $createFolder = @mkdir('' . $dir, (int)$permission, true);
|
@@ -475,8 +453,7 @@ discard block |
||
| 475 | 453 | * |
| 476 | 454 | * @return bool |
| 477 | 455 | */ |
| 478 | - public function moveUploadedFile($tmp_name, $destination) |
|
| 479 | - {
|
|
| 456 | + public function moveUploadedFile($tmp_name, $destination) { |
|
| 480 | 457 | return move_uploaded_file($tmp_name, $destination); |
| 481 | 458 | } |
| 482 | 459 | } |
| 483 | 460 | \ No newline at end of file |