MigrationPlan::getMigration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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
/**
13
 * Represents an available migration to be executed in a specific direction.
14
 */
15
final class MigrationPlan
16
{
17
    /** @var string */
18
    private $direction;
19
    /** @var Version */
20
    private $version;
21
    /** @var AbstractMigration */
22
    private $migration;
23
    /** @var ExecutionResult */
24
    public $result;
25
26 54
    public function __construct(Version $version, AbstractMigration $migration, string $direction)
27
    {
28 54
        $this->version   = $version;
29 54
        $this->migration = $migration;
30 54
        $this->direction = $direction;
31 54
    }
32
33 27
    public function getVersion() : Version
34
    {
35 27
        return $this->version;
36
    }
37
38 4
    public function getResult() : ?ExecutionResult
39
    {
40 4
        return $this->result;
41
    }
42
43 17
    public function markAsExecuted(ExecutionResult $result) : void
44
    {
45 17
        if ($this->result !== null) {
46 1
            throw PlanAlreadyExecuted::new();
47
        }
48
49 17
        $this->result = $result;
50 17
    }
51
52 16
    public function getMigration() : AbstractMigration
53
    {
54 16
        return $this->migration;
55
    }
56
57 26
    public function getDirection() : string
58
    {
59 26
        return $this->direction;
60
    }
61
}
62