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

ChartStatus::getIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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 ChartStatus
8
{
9
    const STATUS_NORMAL = 'NORMAL';
10
    const STATUS_MAJ = 'MAJ';
11
    const STATUS_ERROR = 'ERROR';
12
13
    public const VALUES = [
14
        self::STATUS_NORMAL => self::STATUS_NORMAL,
15
        self::STATUS_MAJ => self::STATUS_MAJ,
16
        self::STATUS_ERROR => self::STATUS_ERROR,
17
    ];
18
19
    private string $value;
20
21
    public function __construct(string $value)
22
    {
23
        self::inArray($value);
24
25
        $this->value = $value;
26
    }
27
28
    public static function inArray(string $value): void
29
    {
30
        Assert::inArray($value, self::VALUES);
31
    }
32
33
    public function getValue(): string
34
    {
35
        return $this->value;
36
    }
37
38
    public function __toString(): string
39
    {
40
        return $this->value;
41
    }
42
43
    public function isNormal(): bool
44
    {
45
        return self::STATUS_NORMAL === $this->value;
46
    }
47
48
    public function isMaj(): bool
49
    {
50
        return self::STATUS_MAJ === $this->value;
51
    }
52
53
    public function isError(): bool
54
    {
55
        return self::STATUS_ERROR === $this->value;
56
    }
57
58
    public static function getStatusChoices(): array
59
    {
60
        return [
61
            'label.chart.status.normal' => self::STATUS_NORMAL,
62
            'label.chart.status.maj' => self::STATUS_MAJ,
63
            'label.chart.status.error' => self::STATUS_ERROR,
64
        ];
65
    }
66
}