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

GroupOrderBy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 18
c 1
b 0
f 0
dl 0
loc 42
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusChoices() 0 6 1
A getValue() 0 3 1
A __toString() 0 3 1
A __construct() 0 5 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 GroupOrderBy
10
{
11
    public const NAME = 'NAME';
12
    public const ID = 'ID';
13
    public const CUSTOM = 'CUSTOM';
14
15
    public const VALUES = [
16
        self::NAME,
17
        self::ID,
18
        self::CUSTOM,
19
    ];
20
21
    private string $value;
22
23
    public function __construct(string $value)
24
    {
25
        self::inArray($value);
26
27
        $this->value = $value;
28
    }
29
30
    public static function inArray(string $value): void
31
    {
32
        Assert::inArray($value, self::VALUES);
33
    }
34
35
    public function getValue(): string
36
    {
37
        return $this->value;
38
    }
39
40
    public function __toString(): string
41
    {
42
        return $this->value;
43
    }
44
45
    public static function getStatusChoices(): array
46
    {
47
        return [
48
            self::NAME => self::NAME,
49
            self::ID => self::ID,
50
            self::CUSTOM => self::CUSTOM,
51
        ];
52
    }
53
}
54