@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @param mixed $offset |
| 136 | 136 | */ |
| 137 | - public function offsetExists($offset){} |
|
| 137 | + public function offsetExists($offset) {} |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * \ArrayAccess unused method |
| 141 | 141 | * |
| 142 | 142 | * @param mixed $offset |
| 143 | 143 | */ |
| 144 | - public function offsetUnset($offset){} |
|
| 144 | + public function offsetUnset($offset) {} |
|
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * \ArrayAccess - get array value from object |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function setDimension($maxWidth, $maxHeight) |
| 180 | 180 | { |
| 181 | - if ( (int) $maxWidth && (int) $maxHeight) { |
|
| 181 | + if ((int) $maxWidth && (int) $maxHeight) { |
|
| 182 | 182 | $this->dimensions = array($maxWidth, $maxHeight); |
| 183 | 183 | } else { |
| 184 | 184 | $this->error = $this->commonUploadErrors[$this->language]['ERROR_03']; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | return false; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $create = !is_dir($dir) ? @mkdir('' . $dir, (int) $permission, true) : true; |
|
| 421 | + $create = !is_dir($dir) ? @mkdir(''.$dir, (int) $permission, true) : true; |
|
| 422 | 422 | |
| 423 | 423 | if (!$create) { |
| 424 | 424 | $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_05'], $dir); |
@@ -113,8 +113,7 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * @param array $_files represents the $_FILES array passed as dependency |
| 115 | 115 | */ |
| 116 | - public function __construct(array $_files = array()) |
|
| 117 | - { |
|
| 116 | + public function __construct(array $_files = array()) { |
|
| 118 | 117 | if (!function_exists('exif_imagetype')) { |
| 119 | 118 | $this->error = $this->commonUploadErrors[$this->language]['ERROR_01']; |
| 120 | 119 | } |
@@ -151,8 +150,7 @@ discard block |
||
| 151 | 150 | * |
| 152 | 151 | * @return string|bool |
| 153 | 152 | */ |
| 154 | - public function offsetGet($offset) |
|
| 155 | - { |
|
| 153 | + public function offsetGet($offset) { |
|
| 156 | 154 | // return false if $_FILES['key'] isn't found |
| 157 | 155 | if (!isset($this->_files[$offset])) { |
| 158 | 156 | $this->error = sprintf($this->commonUploadErrors[$this->language]['ERROR_02'], $offset); |
@@ -177,8 +175,7 @@ discard block |
||
| 177 | 175 | * |
| 178 | 176 | * @return $this |
| 179 | 177 | */ |
| 180 | - public function setDimension($maxWidth, $maxHeight) |
|
| 181 | - { |
|
| 178 | + public function setDimension($maxWidth, $maxHeight) { |
|
| 182 | 179 | if ( (int) $maxWidth && (int) $maxHeight) { |
| 183 | 180 | $this->dimensions = array($maxWidth, $maxHeight); |
| 184 | 181 | } else { |
@@ -193,8 +190,7 @@ discard block |
||
| 193 | 190 | * |
| 194 | 191 | * @return string |
| 195 | 192 | */ |
| 196 | - public function getFullPath() |
|
| 197 | - { |
|
| 193 | + public function getFullPath() { |
|
| 198 | 194 | return $this->fullPath = $this->getLocation().'/'.$this->getName().'.'.$this->getMime(); |
| 199 | 195 | } |
| 200 | 196 | |
@@ -205,8 +201,7 @@ discard block |
||
| 205 | 201 | * |
| 206 | 202 | * @return $this |
| 207 | 203 | */ |
| 208 | - public function setLanguage($lang) |
|
| 209 | - { |
|
| 204 | + public function setLanguage($lang) { |
|
| 210 | 205 | if (isset($this->commonUploadErrors[$lang])) { |
| 211 | 206 | $this->language = $lang; |
| 212 | 207 | } else { |
@@ -221,8 +216,7 @@ discard block |
||
| 221 | 216 | * |
| 222 | 217 | * @return int |
| 223 | 218 | */ |
| 224 | - public function getSize() |
|
| 225 | - { |
|
| 219 | + public function getSize() { |
|
| 226 | 220 | return (int) $this->_files['size']; |
| 227 | 221 | } |
| 228 | 222 | |
@@ -234,8 +228,7 @@ discard block |
||
| 234 | 228 | * |
| 235 | 229 | * @return $this |
| 236 | 230 | */ |
| 237 | - public function setSize($min, $max) |
|
| 238 | - { |
|
| 231 | + public function setSize($min, $max) { |
|
| 239 | 232 | $this->size = array($min, $max); |
| 240 | 233 | return $this; |
| 241 | 234 | } |
@@ -245,8 +238,7 @@ discard block |
||
| 245 | 238 | * |
| 246 | 239 | * @return string |
| 247 | 240 | */ |
| 248 | - public function getJson() |
|
| 249 | - { |
|
| 241 | + public function getJson() { |
|
| 250 | 242 | return json_encode( |
| 251 | 243 | array( |
| 252 | 244 | 'name' => $this->name, |
@@ -265,8 +257,7 @@ discard block |
||
| 265 | 257 | * |
| 266 | 258 | * @return null|string |
| 267 | 259 | */ |
| 268 | - public function getMime() |
|
| 269 | - { |
|
| 260 | + public function getMime() { |
|
| 270 | 261 | if (!$this->mime) { |
| 271 | 262 | $this->mime = $this->getImageMime($this->_files['tmp_name']); |
| 272 | 263 | } |
@@ -281,8 +272,7 @@ discard block |
||
| 281 | 272 | * |
| 282 | 273 | * @return $this |
| 283 | 274 | */ |
| 284 | - public function setMime(array $fileTypes) |
|
| 285 | - { |
|
| 275 | + public function setMime(array $fileTypes) { |
|
| 286 | 276 | $this->mimeTypes = $fileTypes; |
| 287 | 277 | return $this; |
| 288 | 278 | } |
@@ -294,8 +284,7 @@ discard block |
||
| 294 | 284 | * |
| 295 | 285 | * @return null|string |
| 296 | 286 | */ |
| 297 | - protected function getImageMime($tmp_name) |
|
| 298 | - { |
|
| 287 | + protected function getImageMime($tmp_name) { |
|
| 299 | 288 | $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)]; |
| 300 | 289 | if (!$this->mime) { |
| 301 | 290 | return null; |
@@ -309,8 +298,7 @@ discard block |
||
| 309 | 298 | * |
| 310 | 299 | * @return string |
| 311 | 300 | */ |
| 312 | - public function getError() |
|
| 313 | - { |
|
| 301 | + public function getError() { |
|
| 314 | 302 | return $this->error; |
| 315 | 303 | } |
| 316 | 304 | |
@@ -319,8 +307,7 @@ discard block |
||
| 319 | 307 | * |
| 320 | 308 | * @return string |
| 321 | 309 | */ |
| 322 | - public function getName() |
|
| 323 | - { |
|
| 310 | + public function getName() { |
|
| 324 | 311 | if (!$this->name) { |
| 325 | 312 | $this->name = uniqid('', true).'_'.str_shuffle(implode(range('e', 'q'))); |
| 326 | 313 | } |
@@ -335,8 +322,7 @@ discard block |
||
| 335 | 322 | * |
| 336 | 323 | * @return $this |
| 337 | 324 | */ |
| 338 | - public function setName($isNameProvided = null) |
|
| 339 | - { |
|
| 325 | + public function setName($isNameProvided = null) { |
|
| 340 | 326 | if ($isNameProvided) { |
| 341 | 327 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
| 342 | 328 | } |
@@ -349,8 +335,7 @@ discard block |
||
| 349 | 335 | * |
| 350 | 336 | * @return int |
| 351 | 337 | */ |
| 352 | - public function getWidth() |
|
| 353 | - { |
|
| 338 | + public function getWidth() { |
|
| 354 | 339 | if ($this->width != null) { |
| 355 | 340 | return $this->width; |
| 356 | 341 | } |
@@ -365,8 +350,7 @@ discard block |
||
| 365 | 350 | * |
| 366 | 351 | * @return int |
| 367 | 352 | */ |
| 368 | - public function getHeight() |
|
| 369 | - { |
|
| 353 | + public function getHeight() { |
|
| 370 | 354 | if ($this->height != null) { |
| 371 | 355 | return $this->height; |
| 372 | 356 | } |
@@ -381,8 +365,7 @@ discard block |
||
| 381 | 365 | * |
| 382 | 366 | * @return string |
| 383 | 367 | */ |
| 384 | - public function getLocation() |
|
| 385 | - { |
|
| 368 | + public function getLocation() { |
|
| 386 | 369 | if (!$this->location) { |
| 387 | 370 | $this->setLocation(); |
| 388 | 371 | } |
@@ -397,8 +380,7 @@ discard block |
||
| 397 | 380 | * |
| 398 | 381 | * @return bool |
| 399 | 382 | */ |
| 400 | - private function isDirectoryValid($dir) |
|
| 401 | - { |
|
| 383 | + private function isDirectoryValid($dir) { |
|
| 402 | 384 | return !file_exists($dir) && !is_dir($dir) || is_writable($dir); |
| 403 | 385 | } |
| 404 | 386 | |
@@ -410,8 +392,7 @@ discard block |
||
| 410 | 392 | * |
| 411 | 393 | * @return $this |
| 412 | 394 | */ |
| 413 | - public function setLocation($dir = 'bulletproof', $permission = 0666) |
|
| 414 | - { |
|
| 395 | + public function setLocation($dir = 'bulletproof', $permission = 0666) { |
|
| 415 | 396 | $isDirectoryValid = $this->isDirectoryValid($dir); |
| 416 | 397 | |
| 417 | 398 | if (!$isDirectoryValid) { |
@@ -436,8 +417,7 @@ discard block |
||
| 436 | 417 | * |
| 437 | 418 | * @return boolean |
| 438 | 419 | */ |
| 439 | - protected function contraintsValidator() |
|
| 440 | - { |
|
| 420 | + protected function contraintsValidator() { |
|
| 441 | 421 | /* check image for valid mime types and return mime */ |
| 442 | 422 | $this->getImageMime($this->_files['tmp_name']); |
| 443 | 423 | /* validate image mime type */ |
@@ -475,8 +455,7 @@ discard block |
||
| 475 | 455 | * |
| 476 | 456 | * @return false|Image |
| 477 | 457 | */ |
| 478 | - public function upload() |
|
| 479 | - { |
|
| 458 | + public function upload() { |
|
| 480 | 459 | if ($this->error !== '') { |
| 481 | 460 | return false; |
| 482 | 461 | } |
@@ -496,8 +475,7 @@ discard block |
||
| 496 | 475 | * |
| 497 | 476 | * @return bool |
| 498 | 477 | */ |
| 499 | - protected function isSaved($tmp_name, $destination) |
|
| 500 | - { |
|
| 478 | + protected function isSaved($tmp_name, $destination) { |
|
| 501 | 479 | return move_uploaded_file($tmp_name, $destination); |
| 502 | 480 | } |
| 503 | 481 | } |
| 504 | 482 | \ No newline at end of file |