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

Settings   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 14.29%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 31
ccs 2
cts 14
cp 0.1429
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A jsonSerialize() 0 8 1
A resolveId() 0 5 2
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 Settings implements JsonSerializable {
15 8
	public function __construct(
16
		public string $name,
17
		public ?string $id = null,
18
		public bool $allowMarkdown = false,
19
		public string $instructions = '',
20
		/**
21
		 * List of fields to be filled by system administrators when configuring the gateway.
22
		 *
23
		 * @var FieldDefinition[]
24
		 */
25
		public array $fields = [],
26
	) {
27 8
	}
28
29
	#[\Override]
30
	public function jsonSerialize(): mixed {
31
		return [
32
			'name' => $this->name,
33
			'id' => $this->id,
34
			'allow_markdown' => $this->allowMarkdown,
35
			'instructions' => $this->instructions,
36
			'fields' => $this->fields,
37
		];
38
	}
39
40
	protected function resolveId(): string {
41
		if (!empty($this->id)) {
42
			return $this->id;
43
		}
44
		return strtolower((new \ReflectionClass($this))->getShortName());
45
	}
46
}
47