Passed
Pull Request — master (#69)
by Guy
03:20
created

Method::applyRequirements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\MFA\BackupCode;
4
5
use SilverStripe\Core\Injector\Injector;
6
use SilverStripe\Core\Manifest\ModuleLoader;
7
use SilverStripe\MFA\Method\Handler\LoginHandlerInterface;
8
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface;
9
use SilverStripe\MFA\Method\MethodInterface;
10
use SilverStripe\MFA\State\AvailableMethodDetailsInterface;
11
12
class Method implements MethodInterface
13
{
14
    /**
15
     * The number of back-up codes that should be generated for a user. Note that changing this value will not
16
     * regenerate or generate new codes to meet the new number. The user will have to manually regenerate codes to
17
     * receive the new number of codes.
18
     *
19
     * @config
20
     * @var int
21
     */
22
    private static $backup_code_count = 9;
0 ignored issues
show
introduced by
The private property $backup_code_count is not used, and could be removed.
Loading history...
23
24
    /**
25
     * The length of each individual backup code
26
     *
27
     * @config
28
     * @var int
29
     */
30
    private static $backup_code_length = 6;
0 ignored issues
show
introduced by
The private property $backup_code_length is not used, and could be removed.
Loading history...
31
32
    /**
33
     * Get a URL segment for this method. This will be used in URL paths for performing authentication by this method
34
     *
35
     * @return string
36
     */
37
    public function getURLSegment()
38
    {
39
        return 'backup-codes';
40
    }
41
42
    /**
43
     * Return the LoginHandler that is used to start and verify login attempts with this method
44
     *
45
     * @return LoginHandlerInterface
46
     */
47
    public function getLoginHandler()
48
    {
49
        return Injector::inst()->create(LoginHandler::class);
50
    }
51
52
    /**
53
     * Return the RegisterHandler that is used to perform registrations with this method
54
     *
55
     * @return RegisterHandlerInterface
56
     */
57
    public function getRegisterHandler()
58
    {
59
        return Injector::inst()->create(RegisterHandler::class);
60
    }
61
62
    public function getThumbnail()
63
    {
64
        return ModuleLoader::getModule('silverstripe/mfa')
65
            ->getResource('client/dist/images/locked-letter.svg')
66
            ->getURL();
67
    }
68
69
    public function getDetails()
70
    {
71
        return Injector::inst()->create(AvailableMethodDetailsInterface::class, $this);
72
    }
73
74
    public function applyRequirements()
75
    {
76
        // This authenticator bundles client requirements in the main bundle.
77
    }
78
}
79