Completed
Push — master ( e3be9e...9444a3 )
by Morris
73:40 queued 52:27
created

ProviderSet   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getProvider() 0 3 1
A getProviders() 0 3 1
A isProviderMissing() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * @copyright 2018 Christoph Wurst <[email protected]>
6
 *
7
 * @author 2018 Christoph Wurst <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OC\Authentication\TwoFactorAuth;
27
28
use OCP\Authentication\TwoFactorAuth\IProvider;
29
30
/**
31
 * Contains all two-factor provider information for the two-factor login challenge
32
 */
33
class ProviderSet {
34
35
	/** @var IProvider */
36
	private $providers;
37
38
	/** @var bool */
39
	private $providerMissing;
40
41
	/**
42
	 * @param IProvider[] $providers
43
	 * @param bool $providerMissing
44
	 */
45
	public function __construct(array $providers, bool $providerMissing) {
46
		$this->providers = [];
0 ignored issues
show
Documentation Bug introduced by
It seems like array() of type array is incompatible with the declared type object<OCP\Authenticatio...woFactorAuth\IProvider> of property $providers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
		foreach ($providers as $provider) {
48
			$this->providers[$provider->getId()] = $provider;
49
		}
50
		$this->providerMissing = $providerMissing;
51
	}
52
53
	/**
54
	 * @param string $providerId
55
	 * @return IProvider|null
56
	 */
57
	public function getProvider(string $providerId) {
58
		return $this->providers[$providerId] ?? null;
59
	}
60
61
	/**
62
	 * @return IProvider[]
63
	 */
64
	public function getProviders(): array {
65
		return $this->providers;
66
	}
67
68
	public function isProviderMissing(): bool {
69
		return $this->providerMissing;
70
	}
71
72
}
73