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

FieldDefinition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 29
ccs 2
cts 8
cp 0.25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A jsonSerialize() 0 7 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