Passed
Pull Request — master (#245)
by
unknown
03:21
created

GatewayConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author Christoph Wurst <[email protected]>
7
 * @author André Fondse <[email protected]>
8
 *
9
 * Nextcloud - Two-factor Gateway for Telegram
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License, version 3,
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
25
26
namespace OCA\TwoFactorGateway\Service\Gateway\Email;
27
28
use OCA\TwoFactorGateway\AppInfo\Application;
29
use OCA\TwoFactorGateway\Exception\ConfigurationException;
30
use OCA\TwoFactorGateway\Service\Gateway\IGatewayConfig;
31
use OCP\IConfig;
32
33
class GatewayConfig implements IGatewayConfig {
34
35
	/** @var IConfig */
36
	private $config;
37
38
	public function __construct(IConfig $config) {
39
		$this->config = $config;
40
	}
41
42
	private function getOrFail(string $key): string {
0 ignored issues
show
Unused Code introduced by
The method getOrFail() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
43
		$val = $this->config->getAppValue(Application::APP_NAME, $key);
44
		if ($val === '') {
45
			throw new ConfigurationException();
46
		}
47
		return $val;
48
	}
49
50
	public function isComplete(): bool {
51
		$set = $this->config->getAppKeys(Application::APP_NAME);
52
		$expected = [];
53
		return count(array_intersect($set, $expected)) === count($expected);
54
	}
55
56
57
}