Passed
Pull Request — master (#640)
by Vitor
03:36
created

State   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 10
dl 0
loc 32
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 2 1
A __construct() 0 3 1
A disabled() 0 2 1
A enabled() 0 2 1
A verifying() 0 2 1
A isVerifying() 0 2 1
A isDisabled() 0 2 1
1
<?php
2
3
/**
4
 * SPDX-FileCopyrightText: 2024 Christoph Wurst <[email protected]>
5
 * SPDX-License-Identifier: AGPL-3.0-or-later
6
 */
7
8
namespace OCA\TwoFactorGateway\Provider\Gateway;
9
10
class State {
11
	public const DISABLED = 0;
12
	public const VERIFYING = 1;
13
	public const ENABLED = 2;
14
15
	private function __construct(
16
		private int $state,
17
	) {
18
	}
19
20
	public static function disabled(): State {
21
		return new self(self::DISABLED);
22
	}
23
24
	public static function verifying(): State {
25
		return new self(self::VERIFYING);
26
	}
27
28
	public static function enabled(): State {
29
		return new self(self::ENABLED);
30
	}
31
32
	public function isDisabled(): bool {
33
		return $this->state === self::DISABLED;
34
	}
35
36
	public function isVerifying(): bool {
37
		return $this->state === self::VERIFYING;
38
	}
39
40
	public function isEnabled(): bool {
41
		return $this->state === self::ENABLED;
42
	}
43
}
44