@@ -114,12 +114,12 @@ |
||
| 114 | 114 | /** |
| 115 | 115 | * @param mixed $offset |
| 116 | 116 | */ |
| 117 | - public function offsetExists($offset){} |
|
| 117 | + public function offsetExists($offset) {} |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @param mixed $offset |
| 121 | 121 | */ |
| 122 | - public function offsetUnset($offset){} |
|
| 122 | + public function offsetUnset($offset) {} |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Gets array value \ArrayAccess. |
@@ -96,8 +96,7 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * @param array $_files represents the $_FILES array passed as dependency |
| 98 | 98 | */ |
| 99 | - public function __construct(array $_files = array()) |
|
| 100 | - { |
|
| 99 | + public function __construct(array $_files = array()) { |
|
| 101 | 100 | if (!function_exists('exif_imagetype')) { |
| 102 | 101 | $this->error = 'Function \'exif_imagetype\' Not found. Please enable \'php_exif\' in your php.ini'; |
| 103 | 102 | } |
@@ -128,8 +127,7 @@ discard block |
||
| 128 | 127 | * |
| 129 | 128 | * @return string|bool |
| 130 | 129 | */ |
| 131 | - public function offsetGet($offset) |
|
| 132 | - { |
|
| 130 | + public function offsetGet($offset) { |
|
| 133 | 131 | // return false if $_FILES['key'] isn't found |
| 134 | 132 | if (!isset($this->_files[$offset])) { |
| 135 | 133 | $this->error = sprintf('No file input found with name: (%s)', $offset); |
@@ -154,8 +152,7 @@ discard block |
||
| 154 | 152 | * |
| 155 | 153 | * @return $this |
| 156 | 154 | */ |
| 157 | - public function setDimension($maxWidth, $maxHeight) |
|
| 158 | - { |
|
| 155 | + public function setDimension($maxWidth, $maxHeight) { |
|
| 159 | 156 | if ((int) $maxWidth && (int) $maxHeight) { |
| 160 | 157 | $this->dimensions = array($maxWidth, $maxHeight); |
| 161 | 158 | } else { |
@@ -170,8 +167,7 @@ discard block |
||
| 170 | 167 | * |
| 171 | 168 | * @return string |
| 172 | 169 | */ |
| 173 | - public function getFullPath() |
|
| 174 | - { |
|
| 170 | + public function getFullPath() { |
|
| 175 | 171 | return $this->fullPath = $this->getLocation().'/'.$this->getName().'.'.$this->getMime(); |
| 176 | 172 | } |
| 177 | 173 | |
@@ -180,8 +176,7 @@ discard block |
||
| 180 | 176 | * |
| 181 | 177 | * @return int |
| 182 | 178 | */ |
| 183 | - public function getSize() |
|
| 184 | - { |
|
| 179 | + public function getSize() { |
|
| 185 | 180 | return (int) $this->_files['size']; |
| 186 | 181 | } |
| 187 | 182 | |
@@ -193,8 +188,7 @@ discard block |
||
| 193 | 188 | * |
| 194 | 189 | * @return $this |
| 195 | 190 | */ |
| 196 | - public function setSize($min, $max) |
|
| 197 | - { |
|
| 191 | + public function setSize($min, $max) { |
|
| 198 | 192 | $this->size = array($min, $max); |
| 199 | 193 | return $this; |
| 200 | 194 | } |
@@ -204,8 +198,7 @@ discard block |
||
| 204 | 198 | * |
| 205 | 199 | * @return string |
| 206 | 200 | */ |
| 207 | - public function getJson() |
|
| 208 | - { |
|
| 201 | + public function getJson() { |
|
| 209 | 202 | return json_encode( |
| 210 | 203 | array( |
| 211 | 204 | 'name' => $this->name, |
@@ -224,8 +217,7 @@ discard block |
||
| 224 | 217 | * |
| 225 | 218 | * @return null|string |
| 226 | 219 | */ |
| 227 | - public function getMime() |
|
| 228 | - { |
|
| 220 | + public function getMime() { |
|
| 229 | 221 | if (!$this->mime) { |
| 230 | 222 | $this->mime = $this->getImageMime($this->_files['tmp_name']); |
| 231 | 223 | } |
@@ -240,8 +232,7 @@ discard block |
||
| 240 | 232 | * |
| 241 | 233 | * @return $this |
| 242 | 234 | */ |
| 243 | - public function setMime(array $fileTypes) |
|
| 244 | - { |
|
| 235 | + public function setMime(array $fileTypes) { |
|
| 245 | 236 | $this->mimeTypes = $fileTypes; |
| 246 | 237 | return $this; |
| 247 | 238 | } |
@@ -253,8 +244,7 @@ discard block |
||
| 253 | 244 | * |
| 254 | 245 | * @return null|string |
| 255 | 246 | */ |
| 256 | - protected function getImageMime($tmp_name) |
|
| 257 | - { |
|
| 247 | + protected function getImageMime($tmp_name) { |
|
| 258 | 248 | $this->mime = @$this->acceptedMimes[exif_imagetype($tmp_name)]; |
| 259 | 249 | if (!$this->mime) { |
| 260 | 250 | return null; |
@@ -268,8 +258,7 @@ discard block |
||
| 268 | 258 | * |
| 269 | 259 | * @return string|false |
| 270 | 260 | */ |
| 271 | - public function getError() |
|
| 272 | - { |
|
| 261 | + public function getError() { |
|
| 273 | 262 | return $this->error; |
| 274 | 263 | } |
| 275 | 264 | |
@@ -278,8 +267,7 @@ discard block |
||
| 278 | 267 | * |
| 279 | 268 | * @return string |
| 280 | 269 | */ |
| 281 | - public function getName() |
|
| 282 | - { |
|
| 270 | + public function getName() { |
|
| 283 | 271 | if (!$this->name) { |
| 284 | 272 | $this->name = uniqid('', true).'_'.str_shuffle(implode(range('e', 'q'))); |
| 285 | 273 | } |
@@ -294,8 +282,7 @@ discard block |
||
| 294 | 282 | * |
| 295 | 283 | * @return $this |
| 296 | 284 | */ |
| 297 | - public function setName($isNameProvided = null) |
|
| 298 | - { |
|
| 285 | + public function setName($isNameProvided = null) { |
|
| 299 | 286 | if ($isNameProvided) { |
| 300 | 287 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
| 301 | 288 | } |
@@ -308,8 +295,7 @@ discard block |
||
| 308 | 295 | * |
| 309 | 296 | * @return int |
| 310 | 297 | */ |
| 311 | - public function getWidth() |
|
| 312 | - { |
|
| 298 | + public function getWidth() { |
|
| 313 | 299 | if ($this->width != null) { |
| 314 | 300 | return $this->width; |
| 315 | 301 | } |
@@ -324,8 +310,7 @@ discard block |
||
| 324 | 310 | * |
| 325 | 311 | * @return int |
| 326 | 312 | */ |
| 327 | - public function getHeight() |
|
| 328 | - { |
|
| 313 | + public function getHeight() { |
|
| 329 | 314 | if ($this->height != null) { |
| 330 | 315 | return $this->height; |
| 331 | 316 | } |
@@ -340,8 +325,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -395,8 +377,7 @@ discard block |
||
| 395 | 377 | * |
| 396 | 378 | * @return true|false |
| 397 | 379 | */ |
| 398 | - protected function contraintsValidator() |
|
| 399 | - { |
|
| 380 | + protected function contraintsValidator() { |
|
| 400 | 381 | /* check image for valid mime types and return mime */ |
| 401 | 382 | $this->getImageMime($this->_files['tmp_name']); |
| 402 | 383 | /* validate image mime type */ |
@@ -436,8 +417,7 @@ discard block |
||
| 436 | 417 | * |
| 437 | 418 | * @return false|Image |
| 438 | 419 | */ |
| 439 | - public function upload() |
|
| 440 | - { |
|
| 420 | + public function upload() { |
|
| 441 | 421 | if ($this->error || !isset($this->_files['tmp_name'])) { |
| 442 | 422 | return false; |
| 443 | 423 | } |
@@ -461,8 +441,7 @@ discard block |
||
| 461 | 441 | * |
| 462 | 442 | * @return bool |
| 463 | 443 | */ |
| 464 | - protected function isSaved($tmp_name, $destination) |
|
| 465 | - { |
|
| 444 | + protected function isSaved($tmp_name, $destination) { |
|
| 466 | 445 | return move_uploaded_file($tmp_name, $destination); |
| 467 | 446 | } |
| 468 | 447 | } |