Completed
Pull Request — master (#68)
by Tim
03:27
created

ImportProcessorFactory::factory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 73
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 73
ccs 0
cts 43
cp 0
rs 9.0675
cc 1
eloc 40
nc 1
nop 2
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * TechDivision\Import\Cli\Services\ImportProcessorFactory
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\ConfigurationInterface;
24
use TechDivision\Import\Services\ImportProcessor;
25
use TechDivision\Import\Assembler\CategoryAssembler;
26
use TechDivision\Import\Repositories\StoreRepository;
27
use TechDivision\Import\Repositories\TaxClassRepository;
28
use TechDivision\Import\Repositories\LinkTypeRepository;
29
use TechDivision\Import\Repositories\CategoryRepository;
30
use TechDivision\Import\Repositories\StoreWebsiteRepository;
31
use TechDivision\Import\Repositories\EavAttributeRepository;
32
use TechDivision\Import\Repositories\EavEntityTypeRepository;
33
use TechDivision\Import\Repositories\LinkAttributeRepository;
34
use TechDivision\Import\Repositories\CoreConfigDataRepository;
35
use TechDivision\Import\Repositories\CategoryVarcharRepository;
36
use TechDivision\Import\Repositories\EavAttributeSetRepository;
37
use TechDivision\Import\Utils\Generators\CoreConfigDataUidGenerator;
38
39
/**
40
 * Factory to create a new import processor.
41
 *
42
 * @author    Tim Wagner <[email protected]>
43
 * @copyright 2016 TechDivision GmbH <[email protected]>
44
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
45
 * @link      https://github.com/techdivision/import-cli-simple
46
 * @link      http://www.techdivision.com
47
 */
48
class ImportProcessorFactory
49
{
50
51
    /**
52
     * Factory method to create a new import processor instance.
53
     *
54
     * @param \PDO                                       $connection    The PDO connection to use
55
     * @param TechDivision\Import\ConfigurationInterface $configuration The subject configuration
56
     *
57
     * @return object The processor instance
58
     */
59
    public static function factory(\PDO $connection, ConfigurationInterface $configuration)
60
    {
61
62
        // extract Magento edition/version
63
        $utilityClassName = $configuration->getUtilityClassName();
64
65
        // initialize the repository that provides category query functionality
66
        $categoryRepository = new CategoryRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to CategoryRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
67
        $categoryRepository->init();
68
69
        // initialize the repository that provides category varchar value query functionality
70
        $categoryVarcharRepository = new CategoryVarcharRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to CategoryVarcharRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
71
        $categoryVarcharRepository->init();
72
73
        // initialize the repository that provides EAV attribute query functionality
74
        $eavAttributeRepository = new EavAttributeRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to EavAttributeRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
75
        $eavAttributeRepository->init();
76
77
        // initialize the repository that provides EAV attribute set query functionality
78
        $eavAttributeSetRepository = new EavAttributeSetRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to EavAttributeSetRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
79
        $eavAttributeSetRepository->init();
80
81
        // initialize the repository that provides EAV entity type query functionality
82
        $eavEntityTypeRepository = new EavEntityTypeRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to EavEntityTypeRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
83
        $eavEntityTypeRepository->init();
84
85
        // initialize the repository that provides store query functionality
86
        $storeRepository = new StoreRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to StoreRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
87
        $storeRepository->init();
88
89
        // initialize the repository that provides store website query functionality
90
        $storeWebsiteRepository = new StoreWebsiteRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to StoreWebsiteRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
91
        $storeWebsiteRepository->init();
92
93
        // initialize the repository that provides tax class query functionality
94
        $taxClassRepository = new TaxClassRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to TaxClassRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
95
        $taxClassRepository->init();
96
97
        // initialize the repository that provides link type query functionality
98
        $linkTypeRepository = new LinkTypeRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to LinkTypeRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
99
        $linkTypeRepository->init();
100
101
        // initialize the repository that provides link attribute query functionality
102
        $linkAttributeRepository = new LinkAttributeRepository($connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to LinkAttributeRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
103
        $linkAttributeRepository->init();
104
105
        // initialize the repository that provides core config data functionality
106
        $coreConfigDataRepository = new CoreConfigDataRepository(new CoreConfigDataUidGenerator(), $connection, $utilityClassName);
0 ignored issues
show
Unused Code introduced by
The call to CoreConfigDataRepository::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
107
        $coreConfigDataRepository->init();
108
109
        // initialize the category assembler
110
        $categoryAssembler = new CategoryAssembler($categoryRepository, $categoryVarcharRepository);
111
112
        // initialize the import processor
113
        $importProcessor = new ImportProcessor(
114
            $connection,
0 ignored issues
show
Unused Code introduced by
The call to ImportProcessor::__construct() has too many arguments starting with $connection.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
115
            $categoryAssembler,
116
            $categoryRepository,
117
            $categoryVarcharRepository,
118
            $eavAttributeRepository,
119
            $eavAttributeSetRepository,
120
            $eavEntityTypeRepository,
121
            $storeRepository,
122
            $storeWebsiteRepository,
123
            $taxClassRepository,
124
            $linkTypeRepository,
125
            $linkAttributeRepository,
126
            $coreConfigDataRepository
127
        );
128
129
        // return the initialize import processor instance
130
        return $importProcessor;
131
    }
132
}
133