| Total Complexity | 15 |
| Total Lines | 144 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | class File |
||
| 23 | { |
||
| 24 | protected $name; |
||
| 25 | protected $path; |
||
| 26 | protected $dir; |
||
| 27 | protected $mime; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get absolute directory path |
||
| 31 | * |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | 1 | public function getDir() |
|
| 35 | { |
||
| 36 | 1 | return $this->dir; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Set absolute directory path |
||
| 41 | * |
||
| 42 | * @param string $dir Absolute directory path |
||
| 43 | * |
||
| 44 | * @return $this |
||
| 45 | */ |
||
| 46 | 1 | public function setDir($dir) |
|
| 47 | { |
||
| 48 | 1 | $this->dir = $dir; |
|
| 49 | |||
| 50 | 1 | return $this; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get MIME type |
||
| 55 | * |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | 1 | public function getMime() |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Set MIME type |
||
| 65 | * |
||
| 66 | * @param string $mime |
||
| 67 | * @return $this |
||
| 68 | */ |
||
| 69 | 1 | public function setMime($mime) |
|
| 70 | { |
||
| 71 | 1 | $this->mime = $mime; |
|
| 72 | |||
| 73 | 1 | return $this; |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Get file name |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | 1 | public function getName() |
|
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Set file name |
||
| 88 | * |
||
| 89 | * @param string $name File name |
||
| 90 | * |
||
| 91 | * @return $this |
||
| 92 | */ |
||
| 93 | 1 | public function setName($name) |
|
| 94 | { |
||
| 95 | 1 | $this->name = $name; |
|
| 96 | |||
| 97 | 1 | return $this; |
|
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Get absolute file path |
||
| 102 | * |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | 1 | public function getPath() |
|
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Set absolute file path |
||
| 112 | * |
||
| 113 | * @param string $path Absolute path to file |
||
| 114 | * |
||
| 115 | * @return $this |
||
| 116 | */ |
||
| 117 | 1 | public function setPath($path) |
|
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Delete file |
||
| 134 | * |
||
| 135 | * @return bool |
||
| 136 | */ |
||
| 137 | 3 | public function delete() |
|
| 138 | { |
||
| 139 | 3 | if (!file_exists($this->getPath()) || !is_writable($this->getPath())) { |
|
| 140 | 2 | return false; |
|
| 141 | } |
||
| 142 | |||
| 143 | 1 | return unlink($this->getPath()); |
|
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Delete file dir if empty |
||
| 148 | * |
||
| 149 | * @return bool |
||
| 150 | */ |
||
| 151 | 3 | public function deleteDir() |
|
| 166 | } |
||
| 167 | } |
||
| 168 |