Version.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Versions\Versions;
  8. use OCP\Files\FileInfo;
  9. use OCP\IUser;
  10. class Version implements IVersion, IMetadataVersion {
  11. public function __construct(
  12. private int $timestamp,
  13. private int|string $revisionId,
  14. private string $name,
  15. private int|float $size,
  16. private string $mimetype,
  17. private string $path,
  18. private FileInfo $sourceFileInfo,
  19. private IVersionBackend $backend,
  20. private IUser $user,
  21. private array $metadata = [],
  22. ) {
  23. }
  24. public function getBackend(): IVersionBackend {
  25. return $this->backend;
  26. }
  27. public function getSourceFile(): FileInfo {
  28. return $this->sourceFileInfo;
  29. }
  30. public function getRevisionId() {
  31. return $this->revisionId;
  32. }
  33. public function getTimestamp(): int {
  34. return $this->timestamp;
  35. }
  36. public function getSize(): int|float {
  37. return $this->size;
  38. }
  39. public function getSourceFileName(): string {
  40. return $this->name;
  41. }
  42. public function getMimeType(): string {
  43. return $this->mimetype;
  44. }
  45. public function getVersionPath(): string {
  46. return $this->path;
  47. }
  48. public function getUser(): IUser {
  49. return $this->user;
  50. }
  51. public function getMetadata(): array {
  52. return $this->metadata;
  53. }
  54. public function getMetadataValue(string $key): ?string {
  55. return $this->metadata[$key] ?? null;
  56. }
  57. }