Passed
Push — master ( 63912c...2646fd )
by Julius
15:33 queued 12s
created

TemplateFileCreator::getActionLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2021 Julius Härtl <[email protected]>
7
 *
8
 * @author John Molakvoæ <[email protected]>
9
 * @author Julius Härtl <[email protected]>
10
 *
11
 * @license GNU AGPL version 3 or any later version
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 */
27
namespace OCP\Files\Template;
28
29
/**
30
 * @since 21.0.0
31
 */
32
final class TemplateFileCreator implements \JsonSerializable {
33
	protected $appId;
34
	protected $mimetypes = [];
35
	protected $actionName;
36
	protected $fileExtension;
37
	protected $iconClass;
38
	protected $ratio = null;
39
	protected $order = 100;
40
	/**
41
	 * @since 27.0.0
42
	 */
43
	protected string $actionLabel;
44
45
	/**
46
	 * @since 21.0.0
47
	 */
48
	public function __construct(
49
		string $appId, string $actionName, string $fileExtension
50
	) {
51
		$this->appId = $appId;
52
		$this->actionName = $actionName;
53
		$this->fileExtension = $fileExtension;
54
	}
55
56
	/**
57
	 * @since 21.0.0
58
	 */
59
	public function getAppId(): string {
60
		return $this->appId;
61
	}
62
63
	/**
64
	 * @since 21.0.0
65
	 */
66
	public function setIconClass(string $iconClass): TemplateFileCreator {
67
		$this->iconClass = $iconClass;
68
		return $this;
69
	}
70
71
	/**
72
	 * @since 21.0.0
73
	 */
74
	public function addMimetype(string $mimetype): TemplateFileCreator {
75
		$this->mimetypes[] = $mimetype;
76
		return $this;
77
	}
78
79
	/**
80
	 * @since 21.0.0
81
	 */
82
	public function getMimetypes(): array {
83
		return $this->mimetypes;
84
	}
85
86
	/**
87
	 * @since 21.0.0
88
	 */
89
	public function setRatio(float $ratio): TemplateFileCreator {
90
		$this->ratio = $ratio;
91
		return $this;
92
	}
93
94
	/**
95
	 * @param int $order order in which the create action shall be listed
96
	 * @since 21.0.0
97
	 */
98
	public function setOrder(int $order): TemplateFileCreator {
99
		$this->order = $order;
100
		return $this;
101
	}
102
103
	/**
104
	 * @since 21.0.0
105
	 */
106
	public function getOrder(): int {
107
		return $this->order;
108
	}
109
110
	/**
111
	 * @since 27.0.0
112
	 */
113
	public function setActionLabel(string $actionLabel): TemplateFileCreator {
114
		$this->actionLabel = $actionLabel;
115
		return $this;
116
	}
117
118
	/**
119
	 * @since 27.0.0
120
	 */
121
	public function getActionLabel(): string {
122
		return $this->actionLabel;
123
	}
124
125
	/**
126
	 * @since 21.0.0
127
	 */
128
	public function jsonSerialize(): array {
129
		return [
130
			'app' => $this->appId,
131
			'label' => $this->actionName,
132
			'extension' => $this->fileExtension,
133
			'iconClass' => $this->iconClass,
134
			'mimetypes' => $this->mimetypes,
135
			'ratio' => $this->ratio,
136
			'actionLabel' => $this->actionLabel,
137
		];
138
	}
139
}
140