@@ -127,18 +127,18 @@ discard block |
||
| 127 | 127 | * @param mixed $offset |
| 128 | 128 | * @param mixed $value |
| 129 | 129 | */ |
| 130 | - public function offsetSet($offset, $value){}
|
|
| 130 | + public function offsetSet($offset, $value) {}
|
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @param mixed $offset |
| 134 | 134 | * @return null |
| 135 | 135 | */ |
| 136 | - public function offsetExists($offset){}
|
|
| 136 | + public function offsetExists($offset) {}
|
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * @param mixed $offset |
| 140 | 140 | */ |
| 141 | - public function offsetUnset($offset){}
|
|
| 141 | + public function offsetUnset($offset) {}
|
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Gets array value \ArrayAccess |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | public function setLocation($dir = "Uploads", $permission = 0666) |
| 212 | 212 | {
|
| 213 | 213 | if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
|
| 214 | - $createFolder = @mkdir("" . $dir, (int) $permission, true);
|
|
| 214 | + $createFolder = @mkdir("".$dir, (int) $permission, true);
|
|
| 215 | 215 | if (!$createFolder) {
|
| 216 | - throw new BulletproofException("Unable to create folder name: $dir in " . __DIR__);
|
|
| 216 | + throw new BulletproofException("Unable to create folder name: $dir in ".__DIR__);
|
|
| 217 | 217 | return; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | public function getName() |
| 245 | 245 | {
|
| 246 | 246 | if (!$this->name) {
|
| 247 | - return uniqid(true) . "_" . str_shuffle(implode(range("e", "q")));
|
|
| 247 | + return uniqid(true)."_".str_shuffle(implode(range("e", "q")));
|
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | return $this->name; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public function getFullPath() |
| 259 | 259 | {
|
| 260 | - $this->fullPath = $this->location . "/" . $this->name . "." . $this->mime; |
|
| 260 | + $this->fullPath = $this->location."/".$this->name.".".$this->mime; |
|
| 261 | 261 | return $this->fullPath; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function getLocation() |
| 310 | 310 | {
|
| 311 | - if(!$this->location){
|
|
| 311 | + if (!$this->location) {
|
|
| 312 | 312 | $this->setLocation(); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $files = $this->_files; |
| 350 | 350 | |
| 351 | 351 | /* check if required php extension is found */ |
| 352 | - if(!function_exists('exif_imagetype')){
|
|
| 352 | + if (!function_exists('exif_imagetype')) {
|
|
| 353 | 353 | throw new BulletproofException("Function 'exif_imagetype' Not found. Please enable \"php_exif\" in your PHP.ini");
|
| 354 | 354 | } |
| 355 | 355 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | list($minSize, $maxSize) = $image->size; |
| 362 | 362 | |
| 363 | 363 | /* check for common upload errors first */ |
| 364 | - if($error = $this->commonErrors[$files["error"]]){
|
|
| 364 | + if ($error = $this->commonErrors[$files["error"]]) {
|
|
| 365 | 365 | throw new BulletproofException($error); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -388,13 +388,13 @@ discard block |
||
| 388 | 388 | throw new BulletproofException("invalid image width/height");
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - if($image->height < 4 || $image->width < 4){
|
|
| 391 | + if ($image->height < 4 || $image->width < 4) {
|
|
| 392 | 392 | throw new BulletproofException("invalid image width/height");
|
| 393 | 393 | |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /* set and get folder name */ |
| 397 | - $image->fullPath = $image->location. "/" . $image->name . "." . $image->mime; |
|
| 397 | + $image->fullPath = $image->location."/".$image->name.".".$image->mime; |
|
| 398 | 398 | |
| 399 | 399 | /* gather image info for json storage */ |
| 400 | 400 | $image->serialize = array( |
@@ -102,8 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @param array $_files represents the $_FILES array passed as dependency |
| 104 | 104 | */ |
| 105 | - public function __construct(array $_files = []) |
|
| 106 | - {
|
|
| 105 | + public function __construct(array $_files = []) { |
|
| 107 | 106 | $this->_files = $_files; |
| 108 | 107 | } |
| 109 | 108 | |
@@ -114,8 +113,7 @@ discard block |
||
| 114 | 113 | * |
| 115 | 114 | * @return bool|string |
| 116 | 115 | */ |
| 117 | - protected function getImageMime($tmp_name) |
|
| 118 | - {
|
|
| 116 | + protected function getImageMime($tmp_name) { |
|
| 119 | 117 | if (isset($this->imageMimes[exif_imagetype($tmp_name)])) {
|
| 120 | 118 | return $this->imageMimes [exif_imagetype($tmp_name)]; |
| 121 | 119 | } |
@@ -147,8 +145,7 @@ discard block |
||
| 147 | 145 | * |
| 148 | 146 | * @return bool|mixed |
| 149 | 147 | */ |
| 150 | - public function offsetGet($offset) |
|
| 151 | - {
|
|
| 148 | + public function offsetGet($offset) { |
|
| 152 | 149 | if (isset($this->_files[$offset]) && file_exists($this->_files[$offset]["tmp_name"])) {
|
| 153 | 150 | $this->_files = $this->_files[$offset]; |
| 154 | 151 | return true; |
@@ -164,8 +161,7 @@ discard block |
||
| 164 | 161 | * @param null $name |
| 165 | 162 | * @return $this |
| 166 | 163 | */ |
| 167 | - public function setName($name = null) |
|
| 168 | - {
|
|
| 164 | + public function setName($name = null) { |
|
| 169 | 165 | if ($name) {
|
| 170 | 166 | $this->name = filter_var($name, FILTER_SANITIZE_STRING); |
| 171 | 167 | } |
@@ -180,8 +176,7 @@ discard block |
||
| 180 | 176 | * |
| 181 | 177 | * @return $this |
| 182 | 178 | */ |
| 183 | - public function setMime(array $fileTypes) |
|
| 184 | - {
|
|
| 179 | + public function setMime(array $fileTypes) { |
|
| 185 | 180 | $this->mimeTypes = $fileTypes; |
| 186 | 181 | return $this; |
| 187 | 182 | } |
@@ -194,8 +189,7 @@ discard block |
||
| 194 | 189 | * |
| 195 | 190 | * @return $this |
| 196 | 191 | */ |
| 197 | - public function setSize($min, $max) |
|
| 198 | - {
|
|
| 192 | + public function setSize($min, $max) { |
|
| 199 | 193 | $this->size = array($min, $max); |
| 200 | 194 | return $this; |
| 201 | 195 | } |
@@ -208,8 +202,7 @@ discard block |
||
| 208 | 202 | * |
| 209 | 203 | * @return $this |
| 210 | 204 | */ |
| 211 | - public function setLocation($dir = "Uploads", $permission = 0666) |
|
| 212 | - {
|
|
| 205 | + public function setLocation($dir = "Uploads", $permission = 0666) { |
|
| 213 | 206 | if (!file_exists($dir) && !is_dir($dir) && !$this->location) {
|
| 214 | 207 | $createFolder = @mkdir("" . $dir, (int) $permission, true);
|
| 215 | 208 | if (!$createFolder) {
|
@@ -230,8 +223,7 @@ discard block |
||
| 230 | 223 | * |
| 231 | 224 | * @return $this |
| 232 | 225 | */ |
| 233 | - public function setDimension($maxWidth, $maxHeight) |
|
| 234 | - {
|
|
| 226 | + public function setDimension($maxWidth, $maxHeight) { |
|
| 235 | 227 | $this->dimensions = array($maxWidth, $maxHeight); |
| 236 | 228 | return $this; |
| 237 | 229 | } |
@@ -241,8 +233,7 @@ discard block |
||
| 241 | 233 | * |
| 242 | 234 | * @return string |
| 243 | 235 | */ |
| 244 | - public function getName() |
|
| 245 | - {
|
|
| 236 | + public function getName() { |
|
| 246 | 237 | if (!$this->name) {
|
| 247 | 238 | return uniqid(true) . "_" . str_shuffle(implode(range("e", "q")));
|
| 248 | 239 | } |
@@ -255,8 +246,7 @@ discard block |
||
| 255 | 246 | * |
| 256 | 247 | * @return string |
| 257 | 248 | */ |
| 258 | - public function getFullPath() |
|
| 259 | - {
|
|
| 249 | + public function getFullPath() { |
|
| 260 | 250 | $this->fullPath = $this->location . "/" . $this->name . "." . $this->mime; |
| 261 | 251 | return $this->fullPath; |
| 262 | 252 | } |
@@ -266,8 +256,7 @@ discard block |
||
| 266 | 256 | * |
| 267 | 257 | * @return int |
| 268 | 258 | */ |
| 269 | - public function getSize() |
|
| 270 | - {
|
|
| 259 | + public function getSize() { |
|
| 271 | 260 | return (int) $this->_files["size"]; |
| 272 | 261 | } |
| 273 | 262 | |
@@ -276,8 +265,7 @@ discard block |
||
| 276 | 265 | * |
| 277 | 266 | * @return int |
| 278 | 267 | */ |
| 279 | - public function getHeight() |
|
| 280 | - {
|
|
| 268 | + public function getHeight() { |
|
| 281 | 269 | if ($this->height != null) {
|
| 282 | 270 | return $this->height; |
| 283 | 271 | } |
@@ -291,8 +279,7 @@ discard block |
||
| 291 | 279 | * |
| 292 | 280 | * @return int |
| 293 | 281 | */ |
| 294 | - public function getWidth() |
|
| 295 | - {
|
|
| 282 | + public function getWidth() { |
|
| 296 | 283 | if ($this->width != null) {
|
| 297 | 284 | return $this->width; |
| 298 | 285 | } |
@@ -306,8 +293,7 @@ discard block |
||
| 306 | 293 | * |
| 307 | 294 | * @return string |
| 308 | 295 | */ |
| 309 | - public function getLocation() |
|
| 310 | - {
|
|
| 296 | + public function getLocation() { |
|
| 311 | 297 | if(!$this->location){
|
| 312 | 298 | $this->setLocation(); |
| 313 | 299 | } |
@@ -320,8 +306,7 @@ discard block |
||
| 320 | 306 | * |
| 321 | 307 | * @return string |
| 322 | 308 | */ |
| 323 | - public function getJson() |
|
| 324 | - {
|
|
| 309 | + public function getJson() { |
|
| 325 | 310 | return json_encode($this->serialize); |
| 326 | 311 | } |
| 327 | 312 | |
@@ -330,8 +315,7 @@ discard block |
||
| 330 | 315 | * |
| 331 | 316 | * @return string |
| 332 | 317 | */ |
| 333 | - public function getMime() |
|
| 334 | - {
|
|
| 318 | + public function getMime() { |
|
| 335 | 319 | return $this->mime; |
| 336 | 320 | } |
| 337 | 321 | |
@@ -342,8 +326,7 @@ discard block |
||
| 342 | 326 | * |
| 343 | 327 | * @throws BulletproofException |
| 344 | 328 | */ |
| 345 | - public function upload() |
|
| 346 | - {
|
|
| 329 | + public function upload() { |
|
| 347 | 330 | /* modify variable names for convenience */ |
| 348 | 331 | $image = $this; |
| 349 | 332 | $files = $this->_files; |
@@ -425,8 +408,7 @@ discard block |
||
| 425 | 408 | * |
| 426 | 409 | * @return bool |
| 427 | 410 | */ |
| 428 | - public function moveUploadedFile($tmp_name, $destination) |
|
| 429 | - {
|
|
| 411 | + public function moveUploadedFile($tmp_name, $destination) { |
|
| 430 | 412 | return move_uploaded_file($tmp_name, $destination); |
| 431 | 413 | } |
| 432 | 414 | } |