ProductImportMap::getMap()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 55
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 2
Metric Value
cc 2
eloc 41
c 2
b 1
f 2
nc 1
nop 0
dl 0
loc 55
rs 9.264

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
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AkeneoPimMiddlewareConnector\Business\Mapper\Map;
9
10
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig;
11
use SprykerMiddleware\Zed\Process\Business\Mapper\Map\AbstractMap;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...\Mapper\Map\AbstractMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use SprykerMiddleware\Zed\Process\Business\Mapper\Map\MapInterface;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...Mapper\Map\MapInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class ProductImportMap extends AbstractMap
15
{
16
    /**
17
     * @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig
18
     */
19
    protected $config;
20
21
    /**
22
     * @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig $config
23
     */
24
    public function __construct(AkeneoPimMiddlewareConnectorConfig $config)
25
    {
26
        $this->config = $config;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getMap(): array
33
    {
34
        return [
35
            'taxSetName' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

35
            'taxSetName' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
                return $this->config->getTaxSet();
37
            },
38
            'color_code' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
            'color_code' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
                return '';
40
            },
41
            'new_from' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
            'new_from' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
                return null;
43
            },
44
            'new_to' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
            'new_to' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
                return null;
46
            },
47
            'category_key' => 'categories',
48
            'category_product_order' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
            'category_product_order' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
                return 0;
50
            },
51
            'stores' => function ($item) {
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
            'stores' => function (/** @scrutinizer ignore-unused */ $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
                return $this->config->getActiveStoresForProducts();
53
            },
54
            'concrete_sku' => 'identifier',
55
            'abstract_sku' => 'parent.abstract_sku',
56
            'abstract_product_creation' => 'parent.abstract_product_creation',
57
            'prices' => function ($item) {
58
                $result = [];
59
                foreach ($item['values']['price'] as $value) {
60
                    $result[] = [
61
                        'price' => $value['price'],
62
                        'price_type' => $value['type'],
63
                        'currency' => $value['currency'],
64
                        'store' => $value['store'],
65
                        'concrete_sku' => $item['identifier'],
66
                        'value_gross' => $value['price'],
67
                        'value_net' => $value['price'],
68
                    ];
69
                }
70
71
                return $result;
72
            },
73
            'images' => 'values.bild_information',
74
            'picto_images' => 'values.picto_informationen',
75
            'is_active' => 'enabled',
76
            'attributes' => [
77
                'values.attributes',
78
            ],
79
            'localizedAttributes' => [
80
                'values.localizedAttributes',
81
            ],
82
            'relations.others' => 'associations.PACK.product_models',
83
            'relations.x_sell' => 'associations.X_SELL.product_models',
84
            'relations.addon' => 'associations.SUBSTITUTION.product_models',
85
            'is_searchable' => function () {
86
                return true;
87
            },
88
        ];
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getStrategy(): string
95
    {
96
        return MapInterface::MAPPER_STRATEGY_SKIP_UNKNOWN;
97
    }
98
}
99