Completed
Pull Request — master (#133)
by Damian
20:49 queued 18:16
created

MigrationDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 48
ccs 8
cts 16
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A __set_state() 0 11 1
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
    protected $name;
22
    protected $path;
23
    protected $rawDefinition;
24
    protected $status = 0;
25
    protected $steps;
26
    protected $parsingError;
27
28
    /**
29
     * @param string $name
30
     * @param string $path
31
     * @param string $rawDefinition
32
     * @param int $status
33
     * @param MigrationStep[]|MigrationStepsCollection $steps
34
     * @param string $parsingError
35
     */
36 70
    public function __construct($name, $path, $rawDefinition, $status = 0, $steps = array(), $parsingError = null)
37
    {
38 70
        $this->name = $name;
39 70
        $this->path = $path;
40 70
        $this->rawDefinition = $rawDefinition;
41 70
        $this->status = $status;
42 70
        $this->steps = ($steps instanceof MigrationStepsCollection) ? $steps : new MigrationStepsCollection($steps);
43 70
        $this->parsingError = $parsingError;
44 70
    }
45
46
    /**
47
     * Allow the class to be serialized to php using var_export
48
     * @param array $data
49
     * @return static
50
     */
51
    public static function __set_state(array $data)
52
    {
53
        return new static(
54
            $data['name'],
55
            $data['path'],
56
            $data['rawDefinition'],
57
            $data['status'],
58
            $data['steps'],
59
            $data['parsingError']
60
        );
61
    }
62
}
63