Completed
Pull Request — master (#478)
by Luc
01:59
created

Status   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 0
dl 0
loc 41
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A scheduled() 0 4 1
A postponed() 0 4 1
A cancelled() 0 4 1
A toNative() 0 4 1
A equals() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CultuurNet\UDB3\Event\ValueObjects;
6
7
class Status
8
{
9
    private const SCHEDULED = 'scheduled';
10
    private const POSTPONED = 'postponed';
11
    private const CANCELLED = 'cancelled';
12
13
    /**
14
     * @var string
15
     */
16
    private $value;
17
18
    private function __construct(string $value)
19
    {
20
        $this->value = $value;
21
    }
22
23
    public static function scheduled(): Status
24
    {
25
        return new Status(self::SCHEDULED);
26
    }
27
28
    public static function postponed(): Status
29
    {
30
        return new Status(self::POSTPONED);
31
    }
32
33
    public static function cancelled(): Status
34
    {
35
        return new Status(self::CANCELLED);
36
    }
37
38
    public function toNative(): string
39
    {
40
        return $this->value;
41
    }
42
43
    public function equals(Status $status): bool
44
    {
45
        return $this->value === $status->toNative();
46
    }
47
}
48