MigrationState::getMigration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Migration;
4
5
class MigrationState
6
{
7
    /** @var Migration */
8
    protected $migration;
9
10
    /** @var string */
11
    protected $bundleName;
12
13
    /** @var string */
14
    protected $version;
15
16
    /**
17
     * @var bool|null
18
     *  null - not executed
19
     *  true - success
20
     *  false = failure
21
     */
22
    protected $state;
23
24
    /**
25
     * @param Migration   $migration
26
     * @param string|null $bundleName
27
     * @param string|null $version
28
     */
29
    public function __construct(Migration $migration, $bundleName = null, $version = null)
30
    {
31
        $this->migration  = $migration;
32
        $this->bundleName = $bundleName;
33
        $this->version    = $version;
34
    }
35
36
    /**
37
     * @return Migration
38
     */
39
    public function getMigration()
40
    {
41
        return $this->migration;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getBundleName()
48
    {
49
        return $this->bundleName;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getVersion()
56
    {
57
        return $this->version;
58
    }
59
60
    /**
61
     * @return boolean
62
     */
63
    public function isSuccessful()
64
    {
65
        return $this->state === true;
66
    }
67
68
    /**
69
     * Marks a migration as successfully finished
70
     */
71
    public function setSuccessful()
72
    {
73
        $this->state = true;
74
    }
75
76
    /**
77
     * Marks a migration as failed
78
     */
79
    public function setFailed()
80
    {
81
        $this->state = false;
82
    }
83
}
84