Passed
Pull Request — master (#33)
by Robbie
01:49
created

Method   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getURLSegment() 0 3 1
A getRegisterHandler() 0 3 1
A getDetails() 0 3 1
A getLoginHandler() 0 3 1
1
<?php
2
3
namespace SilverStripe\MFA\BackupCode;
4
5
use SilverStripe\Core\Injector\Injector;
6
use SilverStripe\MFA\Method\Handler\LoginHandlerInterface;
7
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface;
8
use SilverStripe\MFA\Method\MethodInterface;
9
use SilverStripe\MFA\State\AvailableMethodDetailsInterface;
10
11
class Method implements MethodInterface
12
{
13
    /**
14
     * The number of back-up codes that should be generated for a user. Note that changing this value will not
15
     * regenerate or generate new codes to meet the new number. The user will have to manually regenerate codes to
16
     * receive the new number of codes.
17
     *
18
     * @config
19
     * @var int
20
     */
21
    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...
22
23
    /**
24
     * The length of each individual backup code
25
     *
26
     * @config
27
     * @var int
28
     */
29
    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...
30
31
    /**
32
     * Get a URL segment for this method. This will be used in URL paths for performing authentication by this method
33
     *
34
     * @return string
35
     */
36
    public function getURLSegment()
37
    {
38
        return 'backup-codes';
39
    }
40
41
    /**
42
     * Return the LoginHandler that is used to start and verify login attempts with this method
43
     *
44
     * @return LoginHandlerInterface
45
     */
46
    public function getLoginHandler()
47
    {
48
        return Injector::inst()->create(LoginHandler::class);
49
    }
50
51
    /**
52
     * Return the RegisterHandler that is used to perform registrations with this method
53
     *
54
     * @return RegisterHandlerInterface
55
     */
56
    public function getRegisterHandler()
57
    {
58
        return Injector::inst()->create(RegisterHandler::class);
59
    }
60
61
    public function getDetails()
62
    {
63
        return Injector::inst()->create(AvailableMethodDetailsInterface::class, $this);
64
    }
65
}
66