aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/Versions/Version.php
blob: e202a69b7d71825ee4cde1ae0ebeb5c02f9a5a34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Files_Versions\Versions;

use OCP\Files\FileInfo;
use OCP\IUser;

class Version implements IVersion, IMetadataVersion {
	public function __construct(
		private int $timestamp,
		private int|string $revisionId,
		private string $name,
		private int|float $size,
		private string $mimetype,
		private string $path,
		private FileInfo $sourceFileInfo,
		private IVersionBackend $backend,
		private IUser $user,
		private array $metadata = [],
	) {
	}

	public function getBackend(): IVersionBackend {
		return $this->backend;
	}

	public function getSourceFile(): FileInfo {
		return $this->sourceFileInfo;
	}

	public function getRevisionId() {
		return $this->revisionId;
	}

	public function getTimestamp(): int {
		return $this->timestamp;
	}

	public function getSize(): int|float {
		return $this->size;
	}

	public function getSourceFileName(): string {
		return $this->name;
	}

	public function getMimeType(): string {
		return $this->mimetype;
	}

	public function getVersionPath(): string {
		return $this->path;
	}

	public function getUser(): IUser {
		return $this->user;
	}

	public function getMetadata(): array {
		return $this->metadata;
	}

	public function getMetadataValue(string $key): ?string {
		return $this->metadata[$key] ?? null;
	}
}