MigrationDefinition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 49
ccs 8
cts 16
cp 0.5
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __set_state() 0 9 1
A __construct() 0 8 2
1
<?php
2
3
namespace Kaliop\eZMigrationBundle\API\Value;
4
5
use Kaliop\eZMigrationBundle\API\Collection\MigrationStepsCollection;
6
7
/**
8
 * @property-read string $name
9
 * @property-read string $path
10
 * @property-read string $rawDefinition
11
 * @property-read integer $status
12
 * @property-read MigrationStepsCollection $steps
13
 * @property-read string $parsingError
14
 */
15
class MigrationDefinition extends AbstractValue
16
{
17
    const STATUS_TO_PARSE = 0;
18
    const STATUS_PARSED = 1;
19
    const STATUS_INVALID = 2;
20
21
    /** @var string filename */
22
    protected $name;
23
    /** @var string full path including the filename, relative to the app's root dir if contained within it */
24
    protected $path;
25
    protected $rawDefinition;
26
    /** @var int */
27
    protected $status = 0;
28
    /** @var MigrationStepsCollection */
29
    protected $steps;
30
    protected $parsingError;
31
32
    /**
33
     * @param string $name
34
     * @param string $path
35
     * @param string $rawDefinition
36
     * @param int $status
37
     * @param MigrationStep[]|MigrationStepsCollection $steps
38
     * @param string $parsingError
39
     */
40 149
    public function __construct($name, $path, $rawDefinition, $status = 0, $steps = array(), $parsingError = null)
41
    {
42 149
        $this->name = $name;
0 ignored issues
show
Bug introduced by
The property name is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
43 149
        $this->path = $path;
0 ignored issues
show
Bug introduced by
The property path is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
44 149
        $this->rawDefinition = $rawDefinition;
0 ignored issues
show
Bug introduced by
The property rawDefinition is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
45 149
        $this->status = $status;
0 ignored issues
show
Bug introduced by
The property status is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
46 149
        $this->steps = ($steps instanceof MigrationStepsCollection) ? $steps : new MigrationStepsCollection($steps);
0 ignored issues
show
Bug introduced by
The property steps is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
47 149
        $this->parsingError = $parsingError;
0 ignored issues
show
Bug introduced by
The property parsingError is declared read-only in Kaliop\eZMigrationBundle...lue\MigrationDefinition.
Loading history...
48 149
    }
49
50
    /**
51
     * Allow the class to be serialized to php using var_export
52
     * @param array $data
53
     * @return static
54
     */
55
    public static function __set_state(array $data)
56
    {
57
        return new static(
58
            $data['name'],
59
            $data['path'],
60
            $data['rawDefinition'],
61
            $data['status'],
62
            $data['steps'],
63
            $data['parsingError']
64
        );
65
    }
66
}
67