State   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 42
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A withStatus() 0 7 1
A getName() 0 3 1
A getTimeExecuted() 0 3 1
A getStatus() 0 3 1
A __construct() 0 6 1
A getTimeCreated() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations;
6
7
use DateTimeInterface;
8
9
/**
10
 * Migration meta information specific to current environment
11
 */
12
final class State
13
{
14
    // Migration status
15
    public const STATUS_UNDEFINED = -1;
16
    public const STATUS_PENDING = 0;
17
    public const STATUS_EXECUTED = 1;
18
19 328
    public function __construct(
20
        private string $name,
21
        private DateTimeInterface $timeCreated,
22
        private int $status = self::STATUS_UNDEFINED,
23
        private ?DateTimeInterface $timeExecuted = null
24
    ) {
25
    }
26
27 304
    public function getName(): string
28
    {
29 304
        return $this->name;
30
    }
31
32 296
    public function getStatus(): int
33
    {
34 296
        return $this->status;
35
    }
36
37 304
    public function getTimeCreated(): DateTimeInterface
38
    {
39 304
        return $this->timeCreated;
40
    }
41
42 8
    public function getTimeExecuted(): ?DateTimeInterface
43
    {
44 8
        return $this->timeExecuted;
45
    }
46
47 296
    public function withStatus(int $status, DateTimeInterface $timeExecuted = null): self
48
    {
49 296
        $state = clone $this;
50 296
        $state->status = $status;
51 296
        $state->timeExecuted = $timeExecuted;
52
53 296
        return $state;
54
    }
55
}
56