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.

ChallengeDefinition   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassname() 0 3 1
A getNumber() 0 3 1
A unserialize() 0 5 1
A __construct() 0 9 3
A serialize() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LM\AuthAbstractor\Model;
6
7
use InvalidArgumentException;
8
use LM\AuthAbstractor\Challenge\IChallenge;
9
use Serializable;
10
11
/**
12
 * Not used yet. Might be in the future.
13
 *
14
 * Currently challenges are specified when instantiating the authentication
15
 * process as an array FQCN strings. However, sometimes, we want to assign data
16
 * to each challenge (e.g. the maximum number of attempts). Storing challenge
17
 * definitions instead might be a solution.
18
 *
19
 * @ignore
20
 * @todo Will later be used to specify a maximum number of attempts per
21
 * challenge.
22
 */
23
class ChallengeDefinition implements Serializable
24
{
25
    /** @var string */
26
    private $classname;
27
28
    /** @var int */
29
    private $number;
30
31
    public function __construct(string $classname, int $number = 1)
32
    {
33
        if (!in_array(IChallenge::class, class_implements($classname), true)) {
34
            throw new InvalidArgumentException();
35
        } elseif ($number < 1) {
36
            throw new InvalidArgumentException();
37
        }
38
        $this->classname = $classname;
39
        $this->number = $number;
40
    }
41
42
    public function getClassname(): string
43
    {
44
        return $this->classname;
45
    }
46
47
    public function getNumber(): int
48
    {
49
        return $this->number;
50
    }
51
52
    public function serialize()
53
    {
54
        return serialize([
55
            $this->classname,
56
            $this->number,
57
        ]);
58
    }
59
60
    public function unserialize($serialized)
61
    {
62
        list(
63
            $this->classname,
64
            $this->number) = unserialize($serialized);
65
    }
66
}
67