State   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A enabled() 0 2 1
A disabled() 0 2 1
A __construct() 0 2 1
A isVerifying() 0 2 1
A isDisabled() 0 2 1
A verifying() 0 2 1
A isEnabled() 0 2 1
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * Nextcloud - Two-factor Gateway
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OCA\TwoFactorGateway\Service\Gateway;
23
24
class State {
25
	public const DISABLED = 0;
26
	public const VERIFYING = 1;
27
	public const ENABLED = 2;
28
29
	/** @var int */
30
	private $state;
31
32
	private function __construct(int $state) {
33
		$this->state = $state;
34
	}
35
36
	public static function disabled(): State {
37
		return new self(self::DISABLED);
38
	}
39
40
	public static function verifying(): State {
41
		return new self(self::VERIFYING);
42
	}
43
44
	public static function enabled(): State {
45
		return new self(self::ENABLED);
46
	}
47
48
	public function isDisabled(): bool {
49
		return $this->state === self::DISABLED;
50
	}
51
52
	public function isVerifying(): bool {
53
		return $this->state === self::VERIFYING;
54
	}
55
56
	public function isEnabled(): bool {
57
		return $this->state === self::ENABLED;
58
	}
59
}
60