Completed
Pull Request — master (#10)
by Tim
08:50
created

ProductBunchProcessorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 191
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 15

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 15
dl 0
loc 191
ccs 0
cts 129
cp 0
rs 9.1666

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProcessorType() 0 4 1
B factory() 0 169 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Cli\Services\ProductBunchProcessorFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-cli-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Cli\Services;
22
23
use TechDivision\Import\Configuration\SubjectInterface;
24
use TechDivision\Import\Product\Repositories\ProductRepository;
25
use TechDivision\Import\Product\Repositories\UrlRewriteRepository;
26
use TechDivision\Import\Repositories\EavAttributeOptionValueRepository;
27
use TechDivision\Import\Product\Actions\UrlRewriteAction;
28
use TechDivision\Import\Product\Actions\ProductAction;
29
use TechDivision\Import\Product\Actions\ProductCategoryAction;
30
use TechDivision\Import\Product\Actions\StockItemAction;
31
use TechDivision\Import\Product\Actions\StockStatusAction;
32
use TechDivision\Import\Product\Actions\ProductWebsiteAction;
33
use TechDivision\Import\Product\Actions\ProductVarcharAction;
34
use TechDivision\Import\Product\Actions\ProductTextAction;
35
use TechDivision\Import\Product\Actions\ProductIntAction;
36
use TechDivision\Import\Product\Actions\ProductDecimalAction;
37
use TechDivision\Import\Product\Actions\ProductDatetimeAction;
38
use TechDivision\Import\Product\Actions\Processors\ProductDeleteProcessor;
39
use TechDivision\Import\Product\Actions\Processors\ProductUpdateProcessor;
40
use TechDivision\Import\Product\Actions\Processors\ProductCreateProcessor;
41
use TechDivision\Import\Product\Actions\Processors\ProductCategoryDeleteProcessor;
42
use TechDivision\Import\Product\Actions\Processors\ProductCategoryCreateProcessor;
43
use TechDivision\Import\Product\Actions\Processors\ProductDatetimeCreateProcessor;
44
use TechDivision\Import\Product\Actions\Processors\ProductDecimalCreateProcessor;
45
use TechDivision\Import\Product\Actions\Processors\ProductIntCreateProcessor;
46
use TechDivision\Import\Product\Actions\Processors\ProductTextCreateProcessor;
47
use TechDivision\Import\Product\Actions\Processors\ProductVarcharCreateProcessor;
48
use TechDivision\Import\Product\Actions\Processors\ProductWebsiteDeleteProcessor;
49
use TechDivision\Import\Product\Actions\Processors\ProductWebsiteCreateProcessor;
50
use TechDivision\Import\Product\Actions\Processors\StockItemDeleteProcessor;
51
use TechDivision\Import\Product\Actions\Processors\StockItemCreateProcessor;
52
use TechDivision\Import\Product\Actions\Processors\StockStatusDeleteProcessor;
53
use TechDivision\Import\Product\Actions\Processors\StockStatusCreateProcessor;
54
use TechDivision\Import\Product\Actions\Processors\UrlRewriteCreateProcessor;
55
use TechDivision\Import\Product\Actions\Processors\UrlRewriteDeleteProcessor;
56
57
/**
58
 * Factory to create a new product bunch processor.
59
 *
60
 * @author    Tim Wagner <[email protected]>
61
 * @copyright 2016 TechDivision GmbH <[email protected]>
62
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
63
 * @link      https://github.com/techdivision/import-cli-simple
64
 * @link      http://www.techdivision.com
65
 */
66
class ProductBunchProcessorFactory extends AbstractProductProcessorFactory
67
{
68
69
    /**
70
     * Return's the processor class name.
71
     *
72
     * @return string The processor class name
73
     */
74
    protected static function getProcessorType()
75
    {
76
        return 'TechDivision\Import\Product\Services\ProductBunchProcessor';
77
    }
78
79
    /**
80
     * Factory method to create a new product processor instance.
81
     *
82
     * @param \PDO                                               $connection    The PDO connection to use
83
     * @param TechDivision\Import\Configuration\SubjectInterface $configuration The subject configuration
84
     *
85
     * @return \TechDivision\Import\Product\Services\ProductProcessor The processor instance
86
     */
87
    public static function factory(\PDO $connection, SubjectInterface $configuration)
88
    {
89
90
        // load the utility class name
91
        $utilityClassName = $configuration->getUtilityClassName();
92
93
        // initialize the repository that provides EAV attribute option value query functionality
94
        $eavAttributeOptionValueRepository = new EavAttributeOptionValueRepository();
95
        $eavAttributeOptionValueRepository->setUtilityClassName($utilityClassName);
96
        $eavAttributeOptionValueRepository->setConnection($connection);
97
        $eavAttributeOptionValueRepository->init();
98
99
        // initialize the repository that provides URL rewrite query functionality
100
        $urlRewriteRepository = new UrlRewriteRepository();
101
        $urlRewriteRepository->setUtilityClassName($utilityClassName);
102
        $urlRewriteRepository->setConnection($connection);
103
        $urlRewriteRepository->init();
104
105
        // initialize the repository that provides product query functionality
106
        $productRepository = new ProductRepository();
107
        $productRepository->setUtilityClassName($utilityClassName);
108
        $productRepository->setConnection($connection);
109
        $productRepository->init();
110
111
        // initialize the action that provides product category CRUD functionality
112
        $productCategoryCreateProcessor = new ProductCategoryCreateProcessor();
113
        $productCategoryCreateProcessor->setUtilityClassName($utilityClassName);
114
        $productCategoryCreateProcessor->setConnection($connection);
115
        $productCategoryCreateProcessor->init();
116
        $productCategoryDeleteProcessor = new ProductCategoryDeleteProcessor();
117
        $productCategoryDeleteProcessor->setUtilityClassName($utilityClassName);
118
        $productCategoryDeleteProcessor->setConnection($connection);
119
        $productCategoryDeleteProcessor->init();
120
        $productCategoryAction = new ProductCategoryAction();
121
        $productCategoryAction->setCreateProcessor($productCategoryCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...\ProductCategoryAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
122
        $productCategoryAction->setDeleteProcessor($productCategoryDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...\ProductCategoryAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
123
124
        // initialize the action that provides product datetime attribute CRUD functionality
125
        $productDatetimeCreateProcessor = new ProductDatetimeCreateProcessor();
126
        $productDatetimeCreateProcessor->setUtilityClassName($utilityClassName);
127
        $productDatetimeCreateProcessor->setConnection($connection);
128
        $productDatetimeCreateProcessor->init();
129
        $productDatetimeAction = new ProductDatetimeAction();
130
        $productDatetimeAction->setCreateProcessor($productDatetimeCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...\ProductDatetimeAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
131
132
        // initialize the action that provides product decimal attribute CRUD functionality
133
        $productDecimalCreateProcessor = new ProductDecimalCreateProcessor();
134
        $productDecimalCreateProcessor->setUtilityClassName($utilityClassName);
135
        $productDecimalCreateProcessor->setConnection($connection);
136
        $productDecimalCreateProcessor->init();
137
        $productDecimalAction = new ProductDecimalAction();
138
        $productDecimalAction->setCreateProcessor($productDecimalCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...s\ProductDecimalAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
139
140
        // initialize the action that provides product integer attribute CRUD functionality
141
        $productIntCreateProcessor = new ProductIntCreateProcessor();
142
        $productIntCreateProcessor->setUtilityClassName($utilityClassName);
143
        $productIntCreateProcessor->setConnection($connection);
144
        $productIntCreateProcessor->init();
145
        $productIntAction = new ProductIntAction();
146
        $productIntAction->setCreateProcessor($productIntCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...tions\ProductIntAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147
148
        // initialize the action that provides product CRUD functionality
149
        $productCreateProcessor = new ProductCreateProcessor();
150
        $productCreateProcessor->setUtilityClassName($utilityClassName);
151
        $productCreateProcessor->setConnection($connection);
152
        $productCreateProcessor->init();
153
        $productDeleteProcessor = new ProductDeleteProcessor();
154
        $productDeleteProcessor->setUtilityClassName($utilityClassName);
155
        $productDeleteProcessor->setConnection($connection);
156
        $productDeleteProcessor->init();
157
        $productUpdateProcessor = new ProductUpdateProcessor();
158
        $productUpdateProcessor->setUtilityClassName($utilityClassName);
159
        $productUpdateProcessor->setConnection($connection);
160
        $productUpdateProcessor->init();
161
        $productAction = new ProductAction();
162
        $productAction->setCreateProcessor($productCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...\Actions\ProductAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
163
        $productAction->setDeleteProcessor($productDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...\Actions\ProductAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
164
        $productAction->setUpdateProcessor($productUpdateProcessor);
0 ignored issues
show
Bug introduced by
The method setUpdateProcessor() does not seem to exist on object<TechDivision\Impo...\Actions\ProductAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
165
166
        // initialize the action that provides product text attribute CRUD functionality
167
        $productTextCreateProcessor = new ProductTextCreateProcessor();
168
        $productTextCreateProcessor->setUtilityClassName($utilityClassName);
169
        $productTextCreateProcessor->setConnection($connection);
170
        $productTextCreateProcessor->init();
171
        $productTextAction = new ProductTextAction();
172
        $productTextAction->setCreateProcessor($productTextCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...ions\ProductTextAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
173
174
        // initialize the action that provides product varchar attribute CRUD functionality
175
        $productVarcharCreateProcessor = new ProductVarcharCreateProcessor();
176
        $productVarcharCreateProcessor->setUtilityClassName($utilityClassName);
177
        $productVarcharCreateProcessor->setConnection($connection);
178
        $productVarcharCreateProcessor->init();
179
        $productVarcharAction = new ProductVarcharAction();
180
        $productVarcharAction->setCreateProcessor($productVarcharCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...s\ProductVarcharAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
181
182
        // initialize the action that provides provides product website CRUD functionality
183
        $productWebsiteCreateProcessor = new ProductWebsiteCreateProcessor();
184
        $productWebsiteCreateProcessor->setUtilityClassName($utilityClassName);
185
        $productWebsiteCreateProcessor->setConnection($connection);
186
        $productWebsiteCreateProcessor->init();
187
        $productWebsiteDeleteProcessor = new ProductWebsiteDeleteProcessor();
188
        $productWebsiteDeleteProcessor->setUtilityClassName($utilityClassName);
189
        $productWebsiteDeleteProcessor->setConnection($connection);
190
        $productWebsiteDeleteProcessor->init();
191
        $productWebsiteAction = new ProductWebsiteAction();
192
        $productWebsiteAction->setCreateProcessor($productWebsiteCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...s\ProductWebsiteAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
193
        $productWebsiteAction->setDeleteProcessor($productWebsiteDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...s\ProductWebsiteAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
194
195
        // initialize the action that provides stock item CRUD functionality
196
        $stockItemCreateProcessor = new StockItemCreateProcessor();
197
        $stockItemCreateProcessor->setUtilityClassName($utilityClassName);
198
        $stockItemCreateProcessor->setConnection($connection);
199
        $stockItemCreateProcessor->init();
200
        $stockItemDeleteProcessor = new StockItemDeleteProcessor();
201
        $stockItemDeleteProcessor->setUtilityClassName($utilityClassName);
202
        $stockItemDeleteProcessor->setConnection($connection);
203
        $stockItemDeleteProcessor->init();
204
        $stockItemAction = new StockItemAction();
205
        $stockItemAction->setCreateProcessor($stockItemCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...ctions\StockItemAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
206
        $stockItemAction->setDeleteProcessor($stockItemDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...ctions\StockItemAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
207
208
        // initialize the action that provides stock status CRUD functionality
209
        $stockStatusCreateProcessor = new StockStatusCreateProcessor();
210
        $stockStatusCreateProcessor->setUtilityClassName($utilityClassName);
211
        $stockStatusCreateProcessor->setConnection($connection);
212
        $stockStatusCreateProcessor->init();
213
        $stockStatusDeleteProcessor = new StockItemDeleteProcessor();
214
        $stockStatusDeleteProcessor->setUtilityClassName($utilityClassName);
215
        $stockStatusDeleteProcessor->setConnection($connection);
216
        $stockStatusDeleteProcessor->init();
217
        $stockStatusAction = new StockStatusAction();
218
        $stockStatusAction->setCreateProcessor($stockStatusCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...ions\StockStatusAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
219
        $stockStatusAction->setDeleteProcessor($stockStatusDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...ions\StockStatusAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
220
221
        // initialize the action that provides URL rewrite CRUD functionality
222
        $urlRewriteCreateProcessor = new UrlRewriteCreateProcessor();
223
        $urlRewriteCreateProcessor->setUtilityClassName($utilityClassName);
224
        $urlRewriteCreateProcessor->setConnection($connection);
225
        $urlRewriteCreateProcessor->init();
226
        $urlRewriteDeleteProcessor = new UrlRewriteDeleteProcessor();
227
        $urlRewriteDeleteProcessor->setUtilityClassName($utilityClassName);
228
        $urlRewriteDeleteProcessor->setConnection($connection);
229
        $urlRewriteDeleteProcessor->init();
230
        $urlRewriteAction = new UrlRewriteAction();
231
        $urlRewriteAction->setCreateProcessor($urlRewriteCreateProcessor);
0 ignored issues
show
Bug introduced by
The method setCreateProcessor() does not seem to exist on object<TechDivision\Impo...tions\UrlRewriteAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
232
        $urlRewriteAction->setDeleteProcessor($urlRewriteDeleteProcessor);
0 ignored issues
show
Bug introduced by
The method setDeleteProcessor() does not seem to exist on object<TechDivision\Impo...tions\UrlRewriteAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
233
234
        // initialize the product processor
235
        $processorType = static::getProcessorType();
236
        $productBunchProcessor = new $processorType();
237
        $productBunchProcessor->setConnection($connection);
238
        $productBunchProcessor->setProductRepository($productRepository);
239
        $productBunchProcessor->setUrlRewriteRepository($urlRewriteRepository);
240
        $productBunchProcessor->setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository);
241
        $productBunchProcessor->setProductCategoryAction($productCategoryAction);
242
        $productBunchProcessor->setProductDatetimeAction($productDatetimeAction);
243
        $productBunchProcessor->setProductDecimalAction($productDecimalAction);
244
        $productBunchProcessor->setProductIntAction($productIntAction);
245
        $productBunchProcessor->setProductAction($productAction);
246
        $productBunchProcessor->setProductTextAction($productTextAction);
247
        $productBunchProcessor->setProductVarcharAction($productVarcharAction);
248
        $productBunchProcessor->setProductWebsiteAction($productWebsiteAction);
249
        $productBunchProcessor->setStockItemAction($stockItemAction);
250
        $productBunchProcessor->setStockStatusAction($stockStatusAction);
251
        $productBunchProcessor->setUrlRewriteAction($urlRewriteAction);
252
253
        // return the instance
254
        return $productBunchProcessor;
255
    }
256
}
257