YubikeyLoginForm::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 6
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Firesphere\YubiAuth\Forms;
4
5
use Firesphere\BootstrapMFA\Forms\BootstrapMFALoginForm;
6
use LogicException;
7
use SilverStripe\Core\Environment;
8
use SilverStripe\Security\MemberAuthenticator\LoginHandler;
9
10
/**
11
 * Class YubikeyLoginForm
12
 * @package Firesphere\YubiAuth\Forms
13
 */
14
class YubikeyLoginForm extends BootstrapMFALoginForm
15
{
16
17
    /**
18
     * YubikeyLoginForm constructor.
19
     *
20
     * @param LoginHandler $handler
21
     * @param string $authenticatorClass
22
     * @param string $name
23
     * @param null $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
Documentation Bug introduced by
Are you sure the doc-type for parameter $actions is correct as it would always require null to be passed?
Loading history...
24
     * @param null $actions
25
     * @param bool $checkCurrentUser
26
     * @throws \LogicException
27
     */
28
    public function __construct(
29
        $handler,
30
        $authenticatorClass,
31
        $name,
32
        $fields = null,
33
        $actions = null,
34
        $checkCurrentUser = true
35
    ) {
36
        if (!Environment::getEnv('YUBIAUTH_CLIENTID')) {
37
            throw new LogicException('YUBIAUTH_CLIENTID Must be enabled to use YubiAuth');
38
        }
39
        if (!Environment::getEnv('YUBIAUTH_APIKEY')) {
40
            throw new LogicException('YUBIAUTH_APIKEY Must be enabled to use YubiAuth');
41
        }
42
43
        parent::__construct($handler, $authenticatorClass, $name, $fields, $actions, $checkCurrentUser);
44
    }
45
46
    /**
47
     * Title of the login form
48
     *
49
     * @return string
50
     */
51
    public function getAuthenticatorName()
52
    {
53
        return _t(self::class . '.TITLE', 'Yubikey Login');
54
    }
55
}
56