Passed
Pull Request — develop (#95)
by BENARD
13:04 queued 39s
created

TeamRequestStatus   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 25
c 1
b 0
f 0
dl 0
loc 69
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A isActive() 0 3 1
A __construct() 0 5 1
A getStatusChoices() 0 7 1
A isAccepted() 0 3 1
A getValue() 0 3 1
A isRefused() 0 3 1
A isCanceled() 0 3 1
A inArray() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\ValueObject;
6
7
use Webmozart\Assert\Assert;
8
9
class TeamRequestStatus
10
{
11
    public const ACTIVE = 'ACTIVE';
12
    public const ACCEPTED = 'ACCEPTED';
13
    public const CANCELED = 'CANCELED';
14
    public const REFUSED = 'REFUSED';
15
16
17
    public const VALUES = [
18
        self::ACTIVE,
19
        self::ACCEPTED,
20
        self::CANCELED,
21
        self::REFUSED,
22
    ];
23
24
    private string $value;
25
26
    public function __construct(string $value)
27
    {
28
        self::inArray($value);
29
30
        $this->value = $value;
31
    }
32
33
    public static function inArray(string $value): void
34
    {
35
        Assert::inArray($value, self::VALUES);
36
    }
37
38
    public function getValue(): string
39
    {
40
        return $this->value;
41
    }
42
43
    public function __toString(): string
44
    {
45
        return $this->value;
46
    }
47
48
    public function isActive(): bool
49
    {
50
        return self::ACTIVE === $this->value;
51
    }
52
53
    public function isAccepted(): bool
54
    {
55
        return self::ACCEPTED === $this->value;
56
    }
57
58
    public function isRefused(): bool
59
    {
60
        return self::REFUSED === $this->value;
61
    }
62
63
    public function isCanceled(): bool
64
    {
65
        return self::CANCELED === $this->value;
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public static function getStatusChoices(): array
72
    {
73
        return [
74
            self::ACTIVE => self::ACTIVE,
75
            self::ACCEPTED => self::ACCEPTED,
76
            self::REFUSED => self::REFUSED,
77
            self::CANCELED => self::CANCELED,
78
        ];
79
    }
80
}
81