@@ -94,8 +94,7 @@ discard block |
||
| 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 |
||
| 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; |
@@ -162,8 +160,7 @@ discard block |
||
| 162 | 160 | * |
| 163 | 161 | * @return $this |
| 164 | 162 | */ |
| 165 | - public function setDimension($maxWidth, $maxHeight) |
|
| 166 | - {
|
|
| 163 | + public function setDimension($maxWidth, $maxHeight) { |
|
| 167 | 164 | $this->dimensions = array($maxWidth, $maxHeight); |
| 168 | 165 | return $this; |
| 169 | 166 | } |
@@ -173,8 +170,7 @@ discard block |
||
| 173 | 170 | * |
| 174 | 171 | * @return string |
| 175 | 172 | */ |
| 176 | - public function getFullPath() |
|
| 177 | - {
|
|
| 173 | + public function getFullPath() { |
|
| 178 | 174 | $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime; |
| 179 | 175 | return $this->fullPath; |
| 180 | 176 | } |
@@ -184,8 +180,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 208 | 202 | * |
| 209 | 203 | * @return string |
| 210 | 204 | */ |
| 211 | - public function getJson() |
|
| 212 | - {
|
|
| 205 | + public function getJson() { |
|
| 213 | 206 | /* gather image info for json storage */ |
| 214 | 207 | return json_encode ( |
| 215 | 208 | array( |
@@ -229,8 +222,7 @@ discard block |
||
| 229 | 222 | * |
| 230 | 223 | * @return null|string |
| 231 | 224 | */ |
| 232 | - public function getMime() |
|
| 233 | - {
|
|
| 225 | + public function getMime() { |
|
| 234 | 226 | if (!$this->mime) {
|
| 235 | 227 | return $this->getImageMime($this->_files['tmp_name']); |
| 236 | 228 | } |
@@ -244,8 +236,7 @@ discard block |
||
| 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 |
||
| 257 | 248 | * |
| 258 | 249 | * @return null|string |
| 259 | 250 | */ |
| 260 | - protected function getImageMime($tmp_name) |
|
| 261 | - {
|
|
| 251 | + protected function getImageMime($tmp_name) { |
|
| 262 | 252 | $mime = @ $this->acceptedMimes[exif_imagetype($tmp_name)]; |
| 263 | 253 | |
| 264 | 254 | if (!$mime) {
|
@@ -273,8 +263,7 @@ discard block |
||
| 273 | 263 | * |
| 274 | 264 | * @return string|false |
| 275 | 265 | */ |
| 276 | - public function getError() |
|
| 277 | - {
|
|
| 266 | + public function getError() { |
|
| 278 | 267 | return $this->error != '' ? $this->error : false; |
| 279 | 268 | } |
| 280 | 269 | |
@@ -283,8 +272,7 @@ discard block |
||
| 283 | 272 | * |
| 284 | 273 | * @return string |
| 285 | 274 | */ |
| 286 | - public function getName() |
|
| 287 | - {
|
|
| 275 | + public function getName() { |
|
| 288 | 276 | if (!$this->name) {
|
| 289 | 277 | return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
|
| 290 | 278 | } |
@@ -298,8 +286,7 @@ discard block |
||
| 298 | 286 | * @param null $isNameProvided |
| 299 | 287 | * @return $this |
| 300 | 288 | */ |
| 301 | - public function setName($isNameProvided = null) |
|
| 302 | - {
|
|
| 289 | + public function setName($isNameProvided = null) { |
|
| 303 | 290 | if ($isNameProvided) {
|
| 304 | 291 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
| 305 | 292 | } |
@@ -312,8 +299,7 @@ discard block |
||
| 312 | 299 | * |
| 313 | 300 | * @return int |
| 314 | 301 | */ |
| 315 | - public function getWidth() |
|
| 316 | - {
|
|
| 302 | + public function getWidth() { |
|
| 317 | 303 | if ($this->width != null) {
|
| 318 | 304 | return $this->width; |
| 319 | 305 | } |
@@ -327,8 +313,7 @@ discard block |
||
| 327 | 313 | * |
| 328 | 314 | * @return int |
| 329 | 315 | */ |
| 330 | - public function getHeight() |
|
| 331 | - {
|
|
| 316 | + public function getHeight() { |
|
| 332 | 317 | if ($this->height != null) {
|
| 333 | 318 | return $this->height; |
| 334 | 319 | } |
@@ -342,8 +327,7 @@ discard block |
||
| 342 | 327 | * |
| 343 | 328 | * @return string |
| 344 | 329 | */ |
| 345 | - public function getLocation() |
|
| 346 | - {
|
|
| 330 | + public function getLocation() { |
|
| 347 | 331 | if (!$this->location) {
|
| 348 | 332 | $this->setLocation(); |
| 349 | 333 | } |
@@ -359,8 +343,7 @@ discard block |
||
| 359 | 343 | * |
| 360 | 344 | * @return $this |
| 361 | 345 | */ |
| 362 | - public function setLocation($dir = 'bulletproof', $permission = 0666) |
|
| 363 | - {
|
|
| 346 | + public function setLocation($dir = 'bulletproof', $permission = 0666) { |
|
| 364 | 347 | if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
|
| 365 | 348 | $createFolder = @mkdir('' . $dir, (int) $permission, true);
|
| 366 | 349 | if (!$createFolder) {
|
@@ -383,8 +366,7 @@ discard block |
||
| 383 | 366 | * This methods validates and uploads the image |
| 384 | 367 | * @return false|null|Image |
| 385 | 368 | */ |
| 386 | - public function upload() |
|
| 387 | - {
|
|
| 369 | + public function upload() { |
|
| 388 | 370 | /* modify variable names for convenience */ |
| 389 | 371 | $image = $this; |
| 390 | 372 | $files = $this->_files; |
@@ -454,8 +436,7 @@ discard block |
||
| 454 | 436 | * |
| 455 | 437 | * @return bool |
| 456 | 438 | */ |
| 457 | - public function moveUploadedFile($tmp_name, $destination) |
|
| 458 | - {
|
|
| 439 | + public function moveUploadedFile($tmp_name, $destination) { |
|
| 459 | 440 | return move_uploaded_file($tmp_name, $destination); |
| 460 | 441 | } |
| 461 | 442 | } |
| 462 | 443 | \ No newline at end of file |