Passed
Push — master ( 2479a1...29894a )
by Vitor
02:30 queued 41s
created

ProviderFactory   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 9
Bugs 0 Features 3
Metric Value
wmc 19
eloc 40
c 9
b 0
f 3
dl 0
loc 47
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
D getProvider() 0 38 18
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\Provider;
25
26
use OCA\TwoFactorGateway\Exception\InvalidSmsProviderException;
27
use OCP\AppFramework\IAppContainer;
28
29
class ProviderFactory {
30
31
	/** @var IAppContainer */
32
	private $container;
33
34
	public function __construct(IAppContainer $container) {
35
		$this->container = $container;
36
	}
37
38
	public function getProvider(string $id): IProvider {
39
		switch ($id) {
40
			case SipGate::PROVIDER_ID:
41
				return $this->container->query(SipGate::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

41
				return /** @scrutinizer ignore-deprecated */ $this->container->query(SipGate::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
42
			case PuzzelSMS::PROVIDER_ID:
43
				return $this->container->query(PuzzelSMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

43
				return /** @scrutinizer ignore-deprecated */ $this->container->query(PuzzelSMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
44
			case PlaySMS::PROVIDER_ID:
45
				return $this->container->query(PlaySMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

45
				return /** @scrutinizer ignore-deprecated */ $this->container->query(PlaySMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
46
			case SMSGlobal::PROVIDER_ID:
47
				return $this->container->query(SMSGlobal::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
				return /** @scrutinizer ignore-deprecated */ $this->container->query(SMSGlobal::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
			case WebSms::PROVIDER_ID:
49
				return $this->container->query(WebSms::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

49
				return /** @scrutinizer ignore-deprecated */ $this->container->query(WebSms::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
50
			case ClockworkSMS::PROVIDER_ID:
51
				return $this->container->query(ClockworkSMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

51
				return /** @scrutinizer ignore-deprecated */ $this->container->query(ClockworkSMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
52
			case EcallSMS::PROVIDER_ID:
53
				return $this->container->query(EcallSMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

53
				return /** @scrutinizer ignore-deprecated */ $this->container->query(EcallSMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
54
			case VoipMs::PROVIDER_ID:
55
				return $this->container->query(VoipMs::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
				return /** @scrutinizer ignore-deprecated */ $this->container->query(VoipMs::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
			case Voipbuster::PROVIDER_ID:
57
				return $this->container->query(Voipbuster::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
				return /** @scrutinizer ignore-deprecated */ $this->container->query(Voipbuster::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
58
			case HuaweiE3531::PROVIDER_ID:
59
				return $this->container->query(HuaweiE3531::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

59
				return /** @scrutinizer ignore-deprecated */ $this->container->query(HuaweiE3531::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
60
			case Sms77Io::PROVIDER_ID:
61
				return $this->container->query(Sms77Io::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

61
				return /** @scrutinizer ignore-deprecated */ $this->container->query(Sms77Io::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
62
			case Ovh::PROVIDER_ID:
63
				return $this->container->query(Ovh::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

63
				return /** @scrutinizer ignore-deprecated */ $this->container->query(Ovh::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
64
			case SpryngSMS::PROVIDER_ID:
65
				return $this->container->query(SpryngSMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

65
				return /** @scrutinizer ignore-deprecated */ $this->container->query(SpryngSMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
66
			case ClickatellCentral::PROVIDER_ID:
67
				return $this->container->query(ClickatellCentral::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

67
				return /** @scrutinizer ignore-deprecated */ $this->container->query(ClickatellCentral::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
68
			case ClickatellPortal::PROVIDER_ID:
69
				return $this->container->query(ClickatellPortal::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
				return /** @scrutinizer ignore-deprecated */ $this->container->query(ClickatellPortal::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
70
			case ClickSend::PROVIDER_ID:
71
				return $this->container->query(ClickSend::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

71
				return /** @scrutinizer ignore-deprecated */ $this->container->query(ClickSend::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
72
			case SerwerSMS::PROVIDER_ID:
73
				return $this->container->query(SerwerSMS::class);
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

73
				return /** @scrutinizer ignore-deprecated */ $this->container->query(SerwerSMS::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
74
			default:
75
				throw new InvalidSmsProviderException("Provider <$id> does not exist");
76
		}
77
	}
78
}
79