DefaultCategoryImportDictionary::getLocaleMap()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 9
rs 10
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 DefaultCategoryImportDictionary extends AbstractDictionary
14
{
15
    /**
16
     * @var array
17
     */
18
    protected static $localeMap;
19
20
    /**
21
     * @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig
22
     */
23
    private $config;
24
25
    /**
26
     * @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig $config
27
     */
28
    public function __construct(AkeneoPimMiddlewareConnectorConfig $config)
29
    {
30
        $this->config = $config;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function getDictionary(): array
37
    {
38
        return [
39
            'localizedAttributes' => [
40
                [
41
                    'LabelsToLocalizedAttributeNames',
42
                    'options' => [
43
                        'defaultLocales' => $this->config->getLocalesForImport(),
44
                    ],
45
                ],
46
                [
47
                    'LocaleKeysToIds',
48
                    'options' => [
49
                        'map' => $this->getLocaleMap(),
50
                    ],
51
                ],
52
            ],
53
            'locales' => [
54
                [
55
                    'LabelsToLocaleIds',
56
                    'options' => [
57
                        'map' => $this->getLocaleMap(),
58
                    ],
59
                ],
60
            ],
61
            'fk_category_template' => function ($value, $payload) {
0 ignored issues
show
Unused Code introduced by
The parameter $value 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

61
            'fk_category_template' => function (/** @scrutinizer ignore-unused */ $value, $payload) {

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...
Unused Code introduced by
The parameter $payload 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

61
            'fk_category_template' => function ($value, /** @scrutinizer ignore-unused */ $payload) {

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...
62
                return $this->config->getFkCategoryTemplate();
63
            },
64
            'parent_category_key' => function ($value) {
65
                if (!$value) {
66
                    return $this->config->getDefaultParentCategoryKey();
67
                }
68
69
                return $value;
70
            },
71
        ];
72
    }
73
74
    /**
75
     * @return array
76
     */
77
    protected function getLocaleMap(): array
78
    {
79
        if (static::$localeMap === null) {
0 ignored issues
show
introduced by
The condition static::localeMap === null is always false.
Loading history...
80
            $content = file_get_contents($this->config->getLocaleMapFilePath());
81
82
            static::$localeMap = array_intersect_key(json_decode($content, true), array_flip($this->config->getLocalesForImport()));
83
        }
84
85
        return static::$localeMap;
86
    }
87
}
88