Completed
Push — master ( 7abd40...aad03f )
by Guy
21s queued 11s
created

Method   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getURLSegment() 0 3 1
A getRegisterHandler() 0 3 1
A getLoginHandler() 0 3 1
A isAvailable() 0 3 1
A getThumbnail() 0 5 1
A getUnavailableMessage() 0 3 1
A applyRequirements() 0 2 1
1
<?php declare(strict_types=1);
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
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(): string
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(): LoginHandlerInterface
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(): RegisterHandlerInterface
57
    {
58
        return Injector::inst()->create(RegisterHandler::class);
59
    }
60
61
    public function getThumbnail(): string
62
    {
63
        return (string) ModuleLoader::getModule('silverstripe/mfa')
64
            ->getResource('client/dist/images/locked-letter.svg')
65
            ->getURL();
66
    }
67
68
    public function applyRequirements(): void
69
    {
70
        // This authenticator bundles client requirements in the main bundle.
71
    }
72
73
    public function isAvailable(): bool
74
    {
75
        return true;
76
    }
77
78
    public function getUnavailableMessage(): string
79
    {
80
        return '';
81
    }
82
}
83