| Total Complexity | 6 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 8 | final class File |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | protected $name; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var UploadedFile |
||
| 17 | */ |
||
| 18 | protected $uploadedFile; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Is uploaded |
||
| 22 | * |
||
| 23 | * @var boolean |
||
| 24 | */ |
||
| 25 | protected $uploaded; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var Exception |
||
| 29 | */ |
||
| 30 | protected $exception; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Storage system returned. |
||
| 34 | * |
||
| 35 | * @var \Symfony\Component\HttpFoundation\File\File|mixed |
||
| 36 | */ |
||
| 37 | protected $details; |
||
| 38 | |||
| 39 | public function __construct( |
||
| 40 | UploadedFile $uploadedFile, string $name, bool $uploaded, $details = null, $exception = null) |
||
| 41 | { |
||
| 42 | $this->uploadedFile = $uploadedFile; |
||
| 43 | $this->name = $name; |
||
| 44 | $this->uploaded = $uploaded; |
||
| 45 | $this->details = $details; |
||
| 46 | $this->exception = $exception; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Gets the key generated by `Namer` |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getName(): string |
||
| 55 | { |
||
| 56 | return $this->name; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Access file details saved in client by this object. |
||
| 61 | * |
||
| 62 | * @return UploadedFile |
||
| 63 | */ |
||
| 64 | public function getUploadedFile(): UploadedFile |
||
| 65 | { |
||
| 66 | return $this->uploadedFile; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Checks whether the file is uploaded successfully. |
||
| 71 | * |
||
| 72 | * @return bool |
||
| 73 | */ |
||
| 74 | public function isUploaded(): bool |
||
| 75 | { |
||
| 76 | return $this->uploaded; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * The exception if the file is uploaded error. |
||
| 81 | * |
||
| 82 | * @return Exception |
||
| 83 | */ |
||
| 84 | public function getException(): ?Exception |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * File details provided by storage layer. |
||
| 91 | * |
||
| 92 | * @return \Symfony\Component\HttpFoundation\File\File|mixed |
||
| 93 | */ |
||
| 94 | public function getDetails() |
||
| 99 |