Completed
Push — master ( 369fe8...bfec8c )
by Guy
12s
created

Method::applyRequirements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace SilverStripe\TOTP;
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
use SilverStripe\View\Requirements;
12
13
/**
14
 * Enables time-based one-time password (TOTP) authentication for the silverstripe/mfa module.
15
 */
16
class Method implements MethodInterface
17
{
18
    public function getURLSegment(): string
19
    {
20
        return 'totp';
21
    }
22
23
    public function getLoginHandler(): LoginHandlerInterface
24
    {
25
        return Injector::inst()->create(LoginHandler::class);
26
    }
27
28
    public function getRegisterHandler(): RegisterHandlerInterface
29
    {
30
        return Injector::inst()->create(RegisterHandler::class);
31
    }
32
33
    public function getThumbnail(): string
34
    {
35
        return ModuleLoader::getModule('silverstripe/totp-authenticator')
36
            ->getResource('client/dist/images/totp.svg')
37
            ->getURL();
38
    }
39
40
    public function applyRequirements(): void
41
    {
42
        Requirements::javascript('silverstripe/totp-authenticator: client/dist/js/bundle.js');
43
        Requirements::css('silverstripe/totp-authenticator: client/dist/styles/bundle.css');
44
    }
45
46
    public function getDetails(): AvailableMethodDetailsInterface
47
    {
48
        return Injector::inst()->create(AvailableMethodDetailsInterface::class, $this);
49
    }
50
}
51