GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

U2fRegistrationRequest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 73
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getSignRequests() 0 3 1
A getRequestAsJson() 0 3 1
A getSignRequestsAsJson() 0 3 1
A getRequest() 0 3 1
A unserialize() 0 5 1
A serialize() 0 5 1
A __construct() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LM\AuthAbstractor\Model;
6
7
use Firehed\U2F\RegisterRequest;
8
use Firehed\U2F\SignRequest;
9
use LM\Common\Model\ArrayObject;
10
use Serializable;
11
12
/**
13
 * This class is only used to store a generated U2F register request so that
14
 * it can returned by some functions.
15
 *
16
 * @todo Delete?
17
 * @internal
18
 * @see \LM\AuthAbstractor\U2f\U2fRegistrationManager
19
 */
20
class U2fRegistrationRequest implements Serializable
21
{
22
    /** @var RegisterRequest */
23
    private $request;
24
25
    /** @var SignRequest[] */
26
    private $signRequests;
27
28
    /**
29
     * @param RegisterRequest $request A Firehed register request.
30
     * @param null|ArrayObject $signRequests An array of sign requests, to
31
     * prevent the user (or rather, maket it easier for them) from registering
32
     * the same U2F token twice.
33
     */
34
    public function __construct(
35
        RegisterRequest $request,
36
        ?ArrayObject $signRequests = null
37
    ) {
38
        $this->request = $request;
39
        if (null !== $signRequests) {
40
            $this->signRequests = $signRequests->toArray(SignRequest::class);
41
        } else {
42
            $this->signRequests = [];
43
        }
44
    }
45
46
    /**
47
     * @return RegisterRequest The Firehed register request.
48
     */
49
    public function getRequest(): RegisterRequest
50
    {
51
        return $this->request;
52
    }
53
54
    /**
55
     * @return string The U2F register request as a JSON string.
56
     */
57
    public function getRequestAsJson(): string
58
    {
59
        return json_encode($this->request);
60
    }
61
62
    /**
63
     * @return ArrayObject An array of sign requests.
64
     */
65
    public function getSignRequests(): ArrayObject
66
    {
67
        return new ArrayObject($this->signRequests, SignRequest::class);
0 ignored issues
show
Deprecated Code introduced by
The class LM\Common\Model\ArrayObject has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

67
        return /** @scrutinizer ignore-deprecated */ new ArrayObject($this->signRequests, SignRequest::class);
Loading history...
68
    }
69
70
    /**
71
     * A JSON representing the sign requests.
72
     *
73
     * @todo Should it be nullable?
74
     */
75
    public function getSignRequestsAsJson(): ?string
76
    {
77
        return json_encode($this->signRequests);
78
    }
79
80
    public function serialize()
81
    {
82
        return serialize([
83
            $this->request,
84
            $this->signRequests,
85
        ]);
86
    }
87
88
    public function unserialize($serialized): void
89
    {
90
        list(
91
            $this->request,
92
            $this->signRequests) = unserialize($serialized);
93
    }
94
}
95