ImportConfiguration   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 75
ccs 20
cts 25
cp 0.8
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A setSourceStorageSelection() 0 6 1
A getSourceStorageSelection() 0 4 1
A setImporterId() 0 10 2
A getImporterId() 0 4 1
A toArray() 0 10 2
A toRun() 0 4 1
1
<?php
2
3
namespace Mathielen\ImportEngine\ValueObject;
4
5
class ImportConfiguration
6
{
7
    private $importerId = null;
8
9
    /**
10
     * @var StorageSelection
11
     */
12
    private $sourceStorageSelection;
13
14 18
    public function __construct(StorageSelection $sourceStorageSelection = null, $importerId = null)
15
    {
16 18
        if ($importerId) {
17 1
            $this->setImporterId($importerId);
18
        }
19 18
        if ($sourceStorageSelection) {
20 1
            $this->setSourceStorageSelection($sourceStorageSelection);
21
        }
22 18
    }
23
24
    /**
25
     * @return ImportConfiguration
26
     */
27 1
    public function setSourceStorageSelection(StorageSelection $sourceStorageSelection)
28
    {
29 1
        $this->sourceStorageSelection = $sourceStorageSelection;
30
31 1
        return $this;
32
    }
33
34
    /**
35
     * @return StorageSelection
36
     */
37
    public function getSourceStorageSelection()
38
    {
39
        return $this->sourceStorageSelection;
40
    }
41
42
    /**
43
     * @return ImportConfiguration
44
     */
45 1
    public function setImporterId($importerId)
46
    {
47 1
        if (empty($importerId)) {
48
            throw new \InvalidArgumentException('importerId must be given');
49
        }
50
51 1
        $this->importerId = $importerId;
52
53 1
        return $this;
54
    }
55
56 1
    public function getImporterId()
57
    {
58 1
        return $this->importerId;
59
    }
60
61 8
    public function toArray()
62
    {
63
        return array(
64 8
            'importerid' => $this->importerId,
65 8
            'sourcestorageselection' => $this->sourceStorageSelection ? array(
66
                'name' => $this->sourceStorageSelection->getName(),
67
                'id' => $this->sourceStorageSelection->getId(),
68
            ) : null,
69
        );
70
    }
71
72
    /**
73
     * @return ImportRun
74
     */
75 9
    public function toRun($createdBy = null)
76
    {
77 9
        return new ImportRun($this, $createdBy);
78
    }
79
}
80