AvailableMethodDetails::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.9332
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SilverStripe\MFA\State;
6
7
use SilverStripe\MFA\Method\MethodInterface;
8
9
class AvailableMethodDetails implements AvailableMethodDetailsInterface
10
{
11
    /**
12
     * @var MethodInterface
13
     */
14
    private $method;
15
16
    /**
17
     * @param MethodInterface $method
18
     */
19
    public function __construct(MethodInterface $method)
20
    {
21
        $this->method = $method;
22
    }
23
24
    public function jsonSerialize(): array
25
    {
26
        return [
27
            'urlSegment' => $this->method->getURLSegment(),
28
            'name' => $this->method->getName(),
29
            'description' => $this->method->getRegisterHandler()->getDescription(),
30
            'supportLink' => $this->method->getRegisterHandler()->getSupportLink(),
31
            'supportText' => $this->method->getRegisterHandler()->getSupportText(),
32
            'thumbnail' => $this->method->getThumbnail(),
33
            'component' => $this->method->getRegisterHandler()->getComponent(),
34
            'isAvailable' => $this->method->isAvailable(),
35
            'unavailableMessage' => $this->method->getUnavailableMessage(),
36
        ];
37
    }
38
}
39