Passed
Branch develop (f589e0)
by BENARD
04:27
created

GameStatus   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 17
c 2
b 0
f 0
dl 0
loc 49
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A inArray() 0 3 1
A __construct() 0 5 1
A getValue() 0 3 1
A getStatusChoices() 0 5 1
A __toString() 0 3 1
A isInactive() 0 3 1
A isActive() 0 3 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\ValueObject;
4
5
use Webmozart\Assert\Assert;
0 ignored issues
show
Bug introduced by
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class GameStatus
8
{
9
    const STATUS_ACTIVE = 'ACTIF';
10
    const STATUS_INACTIVE = 'INACTIF';
11
12
    public const VALUES = [
13
        self::STATUS_ACTIVE,
14
        self::STATUS_INACTIVE,
15
    ];
16
17
    private string $value;
18
19
    public function __construct(string $value)
20
    {
21
        self::inArray($value);
22
23
        $this->value = $value;
24
    }
25
26
    public static function inArray(string $value): void
27
    {
28
        Assert::inArray($value, self::VALUES);
29
    }
30
31
    public function getValue(): string
32
    {
33
        return $this->value;
34
    }
35
36
    public function __toString(): string
37
    {
38
        return $this->value;
39
    }
40
41
    public function isActive(): bool
42
    {
43
        return self::STATUS_ACTIVE === $this->value;
44
    }
45
46
    public function isInactive(): bool
47
    {
48
        return self::STATUS_INACTIVE === $this->value;
49
    }
50
51
    public static function getStatusChoices(): array
52
    {
53
        return [
54
            self::STATUS_ACTIVE => self::STATUS_ACTIVE,
55
            self::STATUS_INACTIVE => self::STATUS_INACTIVE,
56
        ];
57
    }
58
}