1 | <?php |
||
20 | class FileSubmission implements FileSubmissionInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string original name on the client machine |
||
24 | */ |
||
25 | protected $name; |
||
26 | |||
27 | /** |
||
28 | * @var string mime type |
||
29 | */ |
||
30 | protected $type; |
||
31 | |||
32 | /** |
||
33 | * @var string file extension |
||
34 | */ |
||
35 | protected $extension; |
||
36 | |||
37 | /** |
||
38 | * @var int in bytes |
||
39 | */ |
||
40 | protected $size; |
||
41 | |||
42 | /** |
||
43 | * @var string local filepath to the temporary file |
||
44 | */ |
||
45 | protected $tmp_file; |
||
46 | |||
47 | /** |
||
48 | * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
||
49 | * although those aren't expected. |
||
50 | */ |
||
51 | protected $error_code; |
||
52 | |||
53 | /** |
||
54 | * FileSubmission constructor. |
||
55 | * @param $name |
||
56 | * @param $tmp_file |
||
57 | * @param $size |
||
58 | * @param null $error_code |
||
59 | * @throws InvalidArgumentException |
||
60 | */ |
||
61 | public function __construct($name, $tmp_file, $size, $error_code = null) |
||
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getName() |
||
89 | |||
90 | /** |
||
91 | * Gets the file's mime type |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getType() |
||
101 | |||
102 | /** |
||
103 | * @since 4.9.80.p |
||
104 | * @return string |
||
105 | */ |
||
106 | protected function determineType() |
||
114 | |||
115 | /** |
||
116 | * Gets the file's extension. |
||
117 | * @since 4.9.80.p |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getExtension() |
||
127 | |||
128 | /** |
||
129 | * Determine's the file's extension given the temporary file. |
||
130 | * @since 4.9.80.p |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function determineExtension() |
||
144 | |||
145 | /** |
||
146 | * Gets the size of the file |
||
147 | * @return int |
||
148 | */ |
||
149 | public function getSize() |
||
153 | |||
154 | /** |
||
155 | * Gets the path to the temporary file which was uploaded. |
||
156 | * @return string |
||
157 | */ |
||
158 | public function getTmpFile() |
||
162 | |||
163 | /** |
||
164 | * @since 4.9.80.p |
||
165 | * @return string |
||
166 | */ |
||
167 | public function __toString() |
||
171 | |||
172 | /** |
||
173 | * Gets the error code PHP reported for the file upload. |
||
174 | * @return string |
||
175 | */ |
||
176 | public function getErrorCode() |
||
180 | } |
||
181 | // End of file FileSubmission.php |
||
183 |