@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | * @param mixed $value |
| 111 | 111 | * @return null |
| 112 | 112 | */ |
| 113 | - public function offsetSet($offset, $value){}
|
|
| 113 | + public function offsetSet($offset, $value) {}
|
|
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @param mixed $offset |
| 117 | 117 | * @return null |
| 118 | 118 | */ |
| 119 | - public function offsetExists($offset){}
|
|
| 119 | + public function offsetExists($offset) {}
|
|
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * @param mixed $offset |
| 123 | 123 | * @return null |
| 124 | 124 | */ |
| 125 | - public function offsetUnset($offset){}
|
|
| 125 | + public function offsetUnset($offset) {}
|
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Gets array value \ArrayAccess |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | // check for common upload errors |
| 149 | 149 | |
| 150 | - if(isset($this->_files['error'])){
|
|
| 150 | + if (isset($this->_files['error'])) {
|
|
| 151 | 151 | $this->error = $this->commonUploadErrors[$this->_files['error']]; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function getFullPath() |
| 177 | 177 | {
|
| 178 | - $this->fullPath = $this->location . '/' . $this->name . '.' . $this->mime; |
|
| 178 | + $this->fullPath = $this->location.'/'.$this->name.'.'.$this->mime; |
|
| 179 | 179 | return $this->fullPath; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | public function getJson() |
| 212 | 212 | {
|
| 213 | 213 | /* gather image info for json storage */ |
| 214 | - return json_encode ( |
|
| 214 | + return json_encode( |
|
| 215 | 215 | array( |
| 216 | 216 | 'name' => $this->name, |
| 217 | 217 | 'mime' => $this->mime, |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | public function getName() |
| 287 | 287 | {
|
| 288 | 288 | if (!$this->name) {
|
| 289 | - return uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q')));
|
|
| 289 | + return uniqid('', true).'_'.str_shuffle(implode(range('e', 'q')));
|
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | return $this->name; |
@@ -362,16 +362,16 @@ discard block |
||
| 362 | 362 | public function setLocation($dir = 'bulletproof', $permission = 0666) |
| 363 | 363 | {
|
| 364 | 364 | if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
|
| 365 | - $createFolder = @mkdir('' . $dir, (int) $permission, true);
|
|
| 365 | + $createFolder = @mkdir(''.$dir, (int) $permission, true);
|
|
| 366 | 366 | if (!$createFolder) {
|
| 367 | - $this->error = 'Error! Folder ' . $dir . ' could not be created'; |
|
| 367 | + $this->error = 'Error! Folder '.$dir.' could not be created'; |
|
| 368 | 368 | return false; |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /* check if we can create a file in the directory */ |
| 373 | 373 | if (!is_writable($dir)) {
|
| 374 | - $this->error = 'The images directory \'' . $dir . '\' is not writable!'; |
|
| 374 | + $this->error = 'The images directory \''.$dir.'\' is not writable!'; |
|
| 375 | 375 | return false; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if ($files['size'] < $minSize || $files['size'] > $maxSize) {
|
| 418 | 418 | $min = intval($minSize / 1000) ?: 1; |
| 419 | 419 | $max = intval($maxSize / 1000) ?: 1; |
| 420 | - $image->error = 'Image size should be at least ' . $min . ' KB, and no more than ' . $max . ' KB'; |
|
| 420 | + $image->error = 'Image size should be at least '.$min.' KB, and no more than '.$max.' KB'; |
|
| 421 | 421 | return false; |
| 422 | 422 | } |
| 423 | 423 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | list($allowedWidth, $allowedHeight) = $image->dimensions; |
| 426 | 426 | |
| 427 | 427 | if ($image->height > $allowedHeight || $image->width > $allowedWidth) {
|
| 428 | - $image->error = 'Image height/width should be less than ' . $allowedHeight . '/' . $allowedWidth . ' pixels'; |
|
| 428 | + $image->error = 'Image height/width should be less than '.$allowedHeight.'/'.$allowedWidth.' pixels'; |
|
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
@@ -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 |