Completed
Push — master ( 8024bc...f8f0d2 )
by Vitor
14s
created

FieldDefinition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
dl 0
loc 19
ccs 1
cts 1
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7
 * SPDX-License-Identifier: AGPL-3.0-or-later
8
 */
9
10
namespace OCA\TwoFactorGateway\Provider;
11
12
use JsonSerializable;
13
14
class FieldDefinition implements JsonSerializable {
15 8
	public function __construct(
16
		/**
17
		 * The key that will store the value into database. Mandatory to have this item.
18
		 */
19
		public string $field,
20
		/**
21
		 * The label that will be displayed. Mandatory
22
		 */
23
		public string $prompt,
24
		/**
25
		 * The default value when the value isn't provided.
26
		 * Not mandatory to have this item
27
		 */
28
		public string $default = '',
29
		/**
30
		 * Default: false. Not mandatory to have this item
31
		 */
32
		public bool $optional = false,
33
	) {
34 8
	}
35
36
	#[\Override]
37
	public function jsonSerialize(): mixed {
38
		return [
39
			'field' => $this->field,
40
			'prompt' => $this->prompt,
41
			'default' => $this->default,
42
			'optional' => $this->optional,
43
		];
44
	}
45
}
46