Completed
Push — master ( c00544...97496e )
by Guy
12s
created

AvailableMethodDetails::isAvailable()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\MFA\State;
4
5
use SilverStripe\Core\Injector\Injectable;
6
use SilverStripe\MFA\Method\MethodInterface;
7
8
class AvailableMethodDetails implements AvailableMethodDetailsInterface
9
{
10
    use Injectable;
11
12
    /**
13
     * @var MethodInterface
14
     */
15
    private $method;
16
17
    /**
18
     * @param MethodInterface $method
19
     */
20
    public function __construct(MethodInterface $method)
21
    {
22
        $this->method = $method;
23
    }
24
25
    public function getURLSegment(): string
26
    {
27
        return $this->method->getURLSegment();
28
    }
29
30
    public function getName(): string
31
    {
32
        return $this->method->getRegisterHandler()->getName();
33
    }
34
35
    public function getDescription(): string
36
    {
37
        return $this->method->getRegisterHandler()->getDescription();
38
    }
39
40
    public function getSupportLink(): string
41
    {
42
        return $this->method->getRegisterHandler()->getSupportLink();
43
    }
44
45
    public function getThumbnail(): string
46
    {
47
        return $this->method->getThumbnail();
48
    }
49
50
    public function getComponent(): string
51
    {
52
        return $this->method->getRegisterHandler()->getComponent();
53
    }
54
55
    public function isAvailable(): bool
56
    {
57
        return $this->method->getRegisterHandler()->isAvailable();
58
    }
59
60
    public function getUnavailableMessage(): string
61
    {
62
        return $this->method->getRegisterHandler()->getUnavailableMessage();
63
    }
64
65
    public function jsonSerialize()
66
    {
67
        return [
68
            'urlSegment' => $this->getURLSegment(),
69
            'name' => $this->getName(),
70
            'description' => $this->getDescription(),
71
            'supportLink' => $this->getSupportLink(),
72
            'thumbnail' => $this->getThumbnail(),
73
            'component' => $this->getComponent(),
74
            'isAvailable' => $this->isAvailable(),
75
            'unavailableMessage' => $this->isAvailable() ? '' : $this->getUnavailableMessage(),
76
        ];
77
    }
78
}
79