NumberOfTokensPerIdentityOption   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 3 1
A __construct() 0 3 1
A isEnabled() 0 3 1
A getDefault() 0 3 1
A equals() 0 3 1
A getNumberOfTokensPerIdentity() 0 3 1
1
<?php
2
3
/**
4
 * Copyright 2018 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\Stepup\Configuration\Value;
20
21
use JsonSerializable;
22
23
class NumberOfTokensPerIdentityOption implements JsonSerializable
24
{
25
    public const DISABLED = 0;
26
27
    private readonly int $numberOfTokensPerIdentity;
28
29
    public static function getDefault(): self
30
    {
31
        return new self(self::DISABLED);
32
    }
33
34
    public function __construct(int $numberOfTokensPerIdentity)
35
    {
36
        $this->numberOfTokensPerIdentity = $numberOfTokensPerIdentity;
0 ignored issues
show
Bug introduced by
The property numberOfTokensPerIdentity is declared read-only in Surfnet\Stepup\Configura...TokensPerIdentityOption.
Loading history...
37
    }
38
39
    public function equals(NumberOfTokensPerIdentityOption $other): bool
40
    {
41
        return $this->numberOfTokensPerIdentity === $other->numberOfTokensPerIdentity;
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function isEnabled(): bool
48
    {
49
        return $this->numberOfTokensPerIdentity > self::DISABLED;
50
    }
51
52
    public function getNumberOfTokensPerIdentity(): int
53
    {
54
        return $this->numberOfTokensPerIdentity;
55
    }
56
57
    public function jsonSerialize(): int
58
    {
59
        return $this->numberOfTokensPerIdentity;
60
    }
61
}
62