| Total Complexity | 7 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class Uploader { |
||
| 12 | |||
| 13 | /** @var string[] */ |
||
| 14 | protected static $validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'csv', 'doc', 'docx', 'odt', 'pdf', 'txt', 'md', 'mp3', 'wav', 'mpeg']; |
||
| 15 | |||
| 16 | /** @var Directory */ |
||
| 17 | protected $destination; |
||
| 18 | |||
| 19 | /** @var TempFile */ |
||
| 20 | protected $temp; |
||
| 21 | |||
| 22 | /** @var File */ |
||
| 23 | protected $uploaded; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Inicializa o upload para o diretorio de destino |
||
| 27 | * @param Directory $destination |
||
| 28 | */ |
||
| 29 | public function __construct(Directory $destination) { |
||
| 30 | $this->destination = $destination; |
||
| 31 | $this->destination->create(0777); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Retorna a instância do arquivo que foi enviado |
||
| 36 | * @return File |
||
| 37 | */ |
||
| 38 | public function getUploaded() { |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Prepara o upload |
||
| 44 | * @param TempFile $temp |
||
| 45 | * @return boolean |
||
| 46 | */ |
||
| 47 | public function prepare(TempFile $temp) { |
||
| 48 | $success = false; |
||
| 49 | $this->temp = null; |
||
| 50 | if ($temp->exists()) { |
||
| 51 | $success = true; |
||
| 52 | $this->temp = $temp; |
||
| 53 | } |
||
| 54 | return $success; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Faz o upload para o diretório final |
||
| 59 | * @param string $name |
||
| 60 | * @return boolean |
||
| 61 | */ |
||
| 62 | public function upload($name = '') { |
||
| 71 | } |
||
| 72 | |||
| 74 |