Gateway   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

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