AttributeMapDictionary   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 32
c 1
b 0
f 1
dl 0
loc 92
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getSuperAttributeMap() 0 8 2
A getDictionary() 0 36 1
A getLocaleMap() 0 8 2
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\Translator\Dictionary;
9
10
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig;
11
use SprykerMiddleware\Zed\Process\Business\Translator\Dictionary\AbstractDictionary;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...nary\AbstractDictionary 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
13
class AttributeMapDictionary extends AbstractDictionary
14
{
15
    /**
16
     * @var array
17
     */
18
    protected static $localeMap;
19
20
    /**
21
     * @var array
22
     */
23
    protected static $superAttributeMap;
24
25
    /**
26
     * @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig
27
     */
28
    private $config;
29
30
    /**
31
     * @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig $config
32
     */
33
    public function __construct(AkeneoPimMiddlewareConnectorConfig $config)
34
    {
35
        $this->config = $config;
36
    }
37
38
    /**
39
     * @return array
40
     */
41
    public function getDictionary(): array
42
    {
43
        return [
44
            'is_super' => [
45
                [
46
                    'MarkAsSuperAttribute',
47
                    'options' => [
48
                        'map' => $this->getSuperAttributeMap(),
49
                    ],
50
                ],
51
            ],
52
            'options' => [
53
                [
54
                    'AddAttributeOptions',
55
                    'options' => [
56
                        'pageSize' => 100,
57
                    ],
58
                ],
59
            ],
60
            'labels' => [
61
                [
62
                    'LabelsToLocalizedAttributeNames',
63
                    'options' => [
64
                        'key' => 'key_translation',
65
                    ],
66
                ],
67
                'AddAttributeValues',
68
                [
69
                    'LocaleKeysToIds',
70
                    'options' => [
71
                        'map' => $this->getLocaleMap(),
72
                    ],
73
                ],
74
            ],
75
            'labels.*.key_translation' => [
76
                'AttributeEmptyTranslationToKey',
77
            ],
78
        ];
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    protected function getLocaleMap(): array
85
    {
86
        if (static::$localeMap === null) {
0 ignored issues
show
introduced by
The condition static::localeMap === null is always false.
Loading history...
87
            $content = file_get_contents($this->config->getLocaleMapFilePath());
88
            static::$localeMap = json_decode($content, true);
89
        }
90
91
        return static::$localeMap;
92
    }
93
94
    /**
95
     * @return array
96
     */
97
    protected function getSuperAttributeMap(): array
98
    {
99
        if (static::$superAttributeMap === null) {
0 ignored issues
show
introduced by
The condition static::superAttributeMap === null is always false.
Loading history...
100
            $content = file_get_contents($this->config->getSuperAttributeMapFilePath());
101
            static::$superAttributeMap = json_decode($content, true);
102
        }
103
104
        return static::$superAttributeMap;
105
    }
106
}
107