| Total Complexity | 11 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class UploadedFile extends File { |
||
| 13 | |||
| 14 | private $originalName; |
||
| 15 | private $mimeType; |
||
| 16 | private $error; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * 创建文件 |
||
| 20 | * |
||
| 21 | * @param string $path 路径 |
||
| 22 | * @param string $name 文件名 |
||
| 23 | * @param string $mimeType mime类型 |
||
| 24 | * @param integer $error 错误码 |
||
| 25 | */ |
||
| 26 | public function __construct(string $path, string $name, string $mimeType = null, int $error = null) { |
||
| 27 | $this->mimeType = $mimeType ?: 'application/octet-stream'; |
||
| 28 | $this->error = $error ?: UPLOAD_ERR_OK; |
||
| 29 | $this->originalName = pathinfo($name, PATHINFO_FILENAME); |
||
| 30 | parent::__construct($path); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Get the value of error |
||
| 35 | */ |
||
| 36 | public function getError() |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Set the value of error |
||
| 43 | * |
||
| 44 | * @return self |
||
| 45 | */ |
||
| 46 | public function setError($error) |
||
| 47 | { |
||
| 48 | $this->error = $error; |
||
| 49 | |||
| 50 | return $this; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get the value of mimeType |
||
| 55 | */ |
||
| 56 | public function getMimeType() |
||
| 57 | { |
||
| 58 | return $this->mimeType; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Set the value of mimeType |
||
| 63 | * |
||
| 64 | * @return self |
||
| 65 | */ |
||
| 66 | public function setMimeType($mimeType) |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * 判断文件是否可用 |
||
| 75 | * |
||
| 76 | * @return boolean |
||
| 77 | */ |
||
| 78 | public function isValid() |
||
| 81 | } |
||
| 82 | |||
| 83 | public function __destruct() { |
||
| 88 | } |
If you suppress an error, we recommend checking for the error condition explicitly: