Passed
Push — master ( 7e81b0...7eb007 )
by Robbie
12:39 queued 11s
created

Method::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace SilverStripe\MFA\Tests\Stub\BasicMath;
3
4
use SilverStripe\Control\Director;
5
use SilverStripe\Core\Manifest\ModuleLoader;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface;
8
use SilverStripe\MFA\Method\Handler\VerifyHandlerInterface;
9
use SilverStripe\MFA\Method\MethodInterface;
10
11
class Method implements MethodInterface, TestOnly
12
{
13
    /**
14
     * Get a URL segment for this method. This will be used in URL paths for performing authentication by this method
15
     *
16
     * @return string
17
     */
18
    public function getURLSegment(): string
19
    {
20
        return 'basic-math';
21
    }
22
23
    /**
24
     * Return the VerifyHandler that is used to start and check verification attempts with this method
25
     *
26
     * @return VerifyHandlerInterface
27
     */
28
    public function getVerifyHandler(): VerifyHandlerInterface
29
    {
30
        return new MethodVerifyHandler();
31
    }
32
33
    /**
34
     * Return the RegisterHandler that is used to perform registrations with this method
35
     *
36
     * @return RegisterHandlerInterface
37
     */
38
    public function getRegisterHandler(): RegisterHandlerInterface
39
    {
40
        return new MethodRegisterHandler();
41
    }
42
43
    public function getThumbnail(): string
44
    {
45
        return (string) ModuleLoader::getModule('silverstripe/mfa')
46
            ->getResource('client/dist/images/totp.svg')
47
            ->getURL();
48
    }
49
50
    public function applyRequirements(): void
51
    {
52
        // noop
53
    }
54
55
    public function isAvailable(): bool
56
    {
57
        return Director::isDev();
58
    }
59
60
    public function getUnavailableMessage(): string
61
    {
62
        return 'This is a test authenticator, only available in dev mode for tests.';
63
    }
64
65
    public function getName(): string
66
    {
67
        return 'Math problem';
68
    }
69
}
70