aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Files/Conversion/ConversionMimeProvider.php
blob: 0daf4a10648a4252fa5ce964700057a5cf524d24 (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
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCP\Files\Conversion;

use JsonSerializable;

/**
 * A tuple-like object representing both an original and target
 * MIME type for a file conversion
 *
 * @since 31.0.0
 */
class ConversionMimeProvider implements JsonSerializable {
	/**
	 * @param string $from The source MIME type of a file
	 * @param string $to The target MIME type for the file
	 * @param string $extension The file extension for the target MIME type (e.g. 'png')
	 * @param string $displayName The human-readable name of the target MIME type (e.g. 'Image (.png)')
	 *
	 * @since 31.0.0
	 */
	public function __construct(
		private string $from,
		private string $to,
		private string $extension,
		private string $displayName,
	) {
	}

	public function getFrom(): string {
		return $this->from;
	}

	public function getTo(): string {
		return $this->to;
	}

	public function getExtension(): string {
		return $this->extension;
	}

	public function getDisplayName(): string {
		return $this->displayName;
	}

	/**
	 * @return array{from: string, to: string, extension: string, displayName: string}
	 *
	 * @since 31.0.0
	 */
	public function jsonSerialize(): array {
		return [
			'from' => $this->from,
			'to' => $this->to,
			'extension' => $this->extension,
			'displayName' => $this->displayName,
		];
	}
}