RegisteredMethod::getVerifyHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SilverStripe\MFA\Model;
6
7
use SilverStripe\Core\Injector\Injector;
8
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface;
9
use SilverStripe\MFA\Method\Handler\VerifyHandlerInterface;
10
use SilverStripe\MFA\Method\MethodInterface;
11
use SilverStripe\ORM\DataObject;
12
use SilverStripe\Security\Member;
13
14
/**
15
 * @package SilverStripe\MFA\Model
16
 *
17
 * @property int ID
18
 * @property string MethodClassName
19
 * @property string Data
20
 * @method Member Member
21
 */
22
class RegisteredMethod extends DataObject
23
{
24
    private static $table_name = 'MFARegisteredMethod';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
25
26
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
27
        // The class name of the MethodInterface that this record refers to
28
        'MethodClassName' => 'Varchar',
29
        // Data stored as a JSON blob that may contain detail specific to this registration of the authenticator
30
        'Data' => 'Text',
31
    ];
32
33
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
34
        'Member' => Member::class,
35
    ];
36
37
    /**
38
     * @var MethodInterface
39
     */
40
    protected $method;
41
42
    /**
43
     * @return MethodInterface
44
     */
45
    public function getMethod(): MethodInterface
46
    {
47
        if (!$this->method) {
48
            $this->method = Injector::inst()->create($this->MethodClassName);
49
        }
50
        return $this->method;
51
    }
52
53
    /**
54
     * @return VerifyHandlerInterface
55
     */
56
    public function getVerifyHandler(): VerifyHandlerInterface
57
    {
58
        return $this->getMethod()->getVerifyHandler();
59
    }
60
61
    /**
62
     * @return RegisterHandlerInterface
63
     */
64
    public function getRegisterHandler(): RegisterHandlerInterface
65
    {
66
        return $this->getMethod()->getRegisterHandler();
67
    }
68
}
69