Completed
Push — master ( 160c43...fb9933 )
by Markus
05:54
created

Importer::setSourceStorage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
namespace Mathielen\ImportEngine\Importer;
3
4
use Mathielen\ImportEngine\Filter\Filters;
5
use Mathielen\ImportEngine\Storage\StorageInterface;
6
use Mathielen\ImportEngine\Transformation\Transformation;
7
use Mathielen\ImportEngine\Validation\ValidationInterface;
8
use Mathielen\ImportEngine\Validation\DummyValidation;
9
10
class Importer implements ImporterInterface
11
{
12
13
    /**
14
     * @var StorageInterface
15
     */
16
    private $sourceStorage;
17
18
    /**
19
     * @var StorageInterface
20
     */
21
    private $targetStorage;
22
23
    /**
24
     * @var ValidationInterface
25
     */
26
    private $validation;
27
28
    /**
29
     * @var Transformation
30
     */
31
    private $transformation;
32
33
    /**
34
     * @var Filters
35
     */
36
    private $filters;
37
38
    private $context;
39
40
    /**
41
     * @return \Mathielen\ImportEngine\Importer\Importer
42
     */
43 10
    public static function build(StorageInterface $targetStorage)
44
    {
45 10
        return new self($targetStorage);
46
    }
47
48 10
    public function __construct(StorageInterface $targetStorage)
49
    {
50 10
        $this->targetStorage = $targetStorage;
51
52 10
        $this->validation(new DummyValidation());
53 10
        $this->transformation(new Transformation());
54 10
        $this->filters(new Filters());
55 10
    }
56
57
    public function setContext($context)
58
    {
59
        $this->context = $context;
60
    }
61
62 1
    public function getContext()
63
    {
64 1
        return $this->context;
65
    }
66
67
    /**
68
     * @return StorageInterface
69
     */
70 8
    public function targetStorage()
71
    {
72 8
        return $this->targetStorage;
73
    }
74
75
    /**
76
     * @return ValidationInterface
77
     */
78 10
    public function validation(ValidationInterface $validation = null)
79
    {
80 10
        if ($validation) {
81 10
            $this->validation = $validation;
82 10
        }
83
84 10
        return $this->validation;
85
    }
86
87
    /**
88
     * @return \Mathielen\ImportEngine\Transformation\Transformation
89
     */
90 10
    public function transformation(Transformation $transformation = null)
91
    {
92 10
        if ($transformation) {
93 10
            $this->transformation = $transformation;
94 10
        }
95
96 10
        return $this->transformation;
97
    }
98
99
    /**
100
     * @return \Mathielen\ImportEngine\Filter\Filters
101
     */
102 10
    public function filters(Filters $filters = null)
103
    {
104 10
        if ($filters) {
105 10
            $this->filters = $filters;
106 10
        }
107
108 10
        return $this->filters;
109
    }
110
111
    /**
112
     * @return StorageInterface
113
     */
114 1
    public function getSourceStorage()
115
    {
116 1
        return $this->sourceStorage;
117
    }
118
119
    /**
120
     * @return \Mathielen\ImportEngine\Importer\Importer
121
     */
122
    public function setSourceStorage(StorageInterface $sourceStorage)
123
    {
124
        $this->sourceStorage = $sourceStorage;
125
126
        return $this;
127
    }
128
129
}
130