1
0

Version.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  5. *
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\Files_Versions\Versions;
  25. use OCP\Files\FileInfo;
  26. use OCP\IUser;
  27. class Version implements IVersion, INameableVersion {
  28. /** @var int */
  29. private $timestamp;
  30. /** @var int|string */
  31. private $revisionId;
  32. /** @var string */
  33. private $name;
  34. private string $label;
  35. /** @var int|float */
  36. private $size;
  37. /** @var string */
  38. private $mimetype;
  39. /** @var string */
  40. private $path;
  41. /** @var FileInfo */
  42. private $sourceFileInfo;
  43. /** @var IVersionBackend */
  44. private $backend;
  45. /** @var IUser */
  46. private $user;
  47. public function __construct(
  48. int $timestamp,
  49. $revisionId,
  50. string $name,
  51. int|float $size,
  52. string $mimetype,
  53. string $path,
  54. FileInfo $sourceFileInfo,
  55. IVersionBackend $backend,
  56. IUser $user,
  57. string $label = ''
  58. ) {
  59. $this->timestamp = $timestamp;
  60. $this->revisionId = $revisionId;
  61. $this->name = $name;
  62. $this->label = $label;
  63. $this->size = $size;
  64. $this->mimetype = $mimetype;
  65. $this->path = $path;
  66. $this->sourceFileInfo = $sourceFileInfo;
  67. $this->backend = $backend;
  68. $this->user = $user;
  69. }
  70. public function getBackend(): IVersionBackend {
  71. return $this->backend;
  72. }
  73. public function getSourceFile(): FileInfo {
  74. return $this->sourceFileInfo;
  75. }
  76. public function getRevisionId() {
  77. return $this->revisionId;
  78. }
  79. public function getTimestamp(): int {
  80. return $this->timestamp;
  81. }
  82. public function getSize(): int|float {
  83. return $this->size;
  84. }
  85. public function getSourceFileName(): string {
  86. return $this->name;
  87. }
  88. public function getLabel(): string {
  89. return $this->label;
  90. }
  91. public function getMimeType(): string {
  92. return $this->mimetype;
  93. }
  94. public function getVersionPath(): string {
  95. return $this->path;
  96. }
  97. public function getUser(): IUser {
  98. return $this->user;
  99. }
  100. }