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

MigrationPlan   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 46
ccs 18
cts 18
cp 1
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDirection() 0 3 1
A __construct() 0 5 1
A getMigration() 0 3 1
A markAsExecuted() 0 7 2
A getResult() 0 3 1
A getVersion() 0 3 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
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