Passed
Push — master ( 229462...d74785 )
by Andreas
02:20 queued 14s
created

MigrationPlan::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Metadata;
6
7
use Doctrine\Migrations\AbstractMigration;
8
use Doctrine\Migrations\Exception\PlanAlreadyExecuted;
9
use Doctrine\Migrations\Version\ExecutionResult;
10
use Doctrine\Migrations\Version\Version;
11
12
final class MigrationPlan
13
{
14
    /** @var string */
15
    private $direction;
16
    /** @var Version */
17
    private $version;
18
    /** @var AbstractMigration */
19
    private $migration;
20
21
    /** @var ExecutionResult */
22
    public $result;
23
24 42
    public function __construct(Version $version, AbstractMigration $migration, string $direction)
25
    {
26 42
        $this->version   = $version;
27 42
        $this->migration = $migration;
28 42
        $this->direction = $direction;
29 42
    }
30
31 22
    public function getVersion() : Version
32
    {
33 22
        return $this->version;
34
    }
35
36 3
    public function getResult() : ?ExecutionResult
37
    {
38 3
        return $this->result;
39
    }
40
41 12
    public function markAsExecuted(ExecutionResult $result) : void
42
    {
43 12
        if ($this->result !== null) {
44 1
            throw PlanAlreadyExecuted::new();
45
        }
46
47 12
        $this->result = $result;
48 12
    }
49
50 11
    public function getMigration() : AbstractMigration
51
    {
52 11
        return $this->migration;
53
    }
54
55 22
    public function getDirection() : string
56
    {
57 22
        return $this->direction;
58
    }
59
}
60