Completed
Pull Request — master (#92)
by Christoph
02:02
created

State   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

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

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
25
class State {
26
27
	const DISABLED = 0;
28
	const VERIFYING = 1;
29
	const ENABLED = 2;
30
31
	/** @var int */
32
	private $state;
33
34
	private function __construct(int $state) {
35
		$this->state = $state;
36
	}
37
38
	public static function disabled(): State {
39
		return new self(self::DISABLED);
40
	}
41
42
	public static function verifying(): State {
43
		return new self(self::VERIFYING);
44
	}
45
46
	public static function enabled(): State {
47
		return new self(self::ENABLED);
48
	}
49
50
	public function isDisabled(): bool {
51
		return $this->state === self::DISABLED;
52
	}
53
54
	public function isVerifying(): bool {
55
		return $this->state === self::DISABLED;
56
	}
57
58
	public function isEnabled(): bool {
59
		return $this->state === self::DISABLED;
60
	}
61
62
}
63