@@ -96,14 +96,14 @@ abstract class AbstractAttachment
9696 /**
9797 * Constructor.
9898 *
99- * @param mixed $id attachment id
99+ * @param mixed $attachmentId attachment id
100100 */
101- public function __construct (mixed $ id = null )
101+ public function __construct (mixed $ attachmentId = null )
102102 {
103103 $ this ->db = Database::getInstance ();
104104
105- if (null !== $ id ) {
106- $ this ->id = $ id ;
105+ if (null !== $ attachmentId ) {
106+ $ this ->id = $ attachmentId ;
107107 $ this ->getMeta ();
108108 }
109109 }
@@ -173,7 +173,7 @@ public function setKey(?string $key, bool $default = true): void
173173 $ this ->key = $ key ;
174174 $ this ->encrypted = null !== $ key ;
175175 // Not default means the key was set explicitly
176- // for this attachment, so lets hash it
176+ // for this attachment, so let's hash it
177177 if (!$ this ->encrypted ) {
178178 return ;
179179 }
@@ -204,9 +204,9 @@ public function getId(): int
204204 /**
205205 * Sets attachment id.
206206 */
207- public function setId (int $ id ): void
207+ public function setId (int $ attachmentId ): void
208208 {
209- $ this ->id = $ id ;
209+ $ this ->id = $ attachmentId ;
210210 }
211211
212212 /**
@@ -220,11 +220,11 @@ public function getRecordId(): int
220220 /**
221221 * Set record id.
222222 *
223- * @param int $id record id
223+ * @param int $recordId record id
224224 */
225- public function setRecordId (int $ id ): void
225+ public function setRecordId (int $ recordId ): void
226226 {
227- $ this ->recordId = $ id ;
227+ $ this ->recordId = $ recordId ;
228228 }
229229
230230 /**
@@ -268,34 +268,33 @@ public function saveMeta(): int
268268 return $ this ->id ;
269269 }
270270
271- /**
272- * Returns filename.
273- */
274271 public function getFilename (): string
275272 {
276273 return $ this ->filename ;
277274 }
278275
279- /**
280- * Returns the MIME type
281- */
282276 public function getMimeType (): string
283277 {
284278 return $ this ->mimeType ;
285279 }
286280
281+ public function getFilesize (): int
282+ {
283+ return $ this ->filesize ;
284+ }
285+
286+ public function getRealHash (): string
287+ {
288+ return $ this ->realHash ;
289+ }
290+
287291 /**
288292 * Update several meta things after it was saved.
289293 */
290294 protected function postUpdateMeta (): void
291295 {
292296 $ sql = sprintf (
293- "
294- UPDATE
295- %sfaqattachment
296- SET virtual_hash = '%s',
297- mime_type = '%s'
298- WHERE id = %d " ,
297+ "UPDATE %sfaqattachment SET virtual_hash = '%s', mime_type = '%s' WHERE id = %d " ,
299298 Database::getTablePrefix (),
300299 $ this ->db ->escape ($ this ->virtualHash ),
301300 $ this ->readMimeType (),
@@ -320,14 +319,11 @@ protected function readMimeType(): string
320319 /**
321320 * Generate hash based on current conditions.
322321 *
323- * @return string
324- *
322+ * @return string|null NOTE The way a file is saved in the filesystem
325323 * NOTE The way a file is saved in the filesystem
326324 * is based on md5 hash. If the file is unencrypted,
327- * it's md5 hash is used directly, otherwise a
325+ * it md5 hash is used directly, otherwise a
328326 * hash based on several tokens gets generated.
329- *
330- * @return string|null
331327 * @throws AttachmentException
332328 */
333329 protected function mkVirtualHash (): ?string
0 commit comments