CategoryImportDictionary   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
c 1
b 0
f 1
dl 0
loc 60
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDictionary() 0 22 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 CategoryImportDictionary 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
                'LabelsToLocalizedAttributeNames',
41
                [
42
                    'LocaleKeysToIds',
43
                    'options' => [
44
                        'map' => $this->getLocaleMap(),
45
                    ],
46
                ],
47
            ],
48
            'locales' => [
49
                [
50
                    'LabelsToLocaleIds',
51
                    'options' => [
52
                        'map' => $this->getLocaleMap(),
53
                    ],
54
                ],
55
            ],
56
            'fk_category_template' => function ($value, $payload) {
0 ignored issues
show
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

56
            '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...
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

56
            '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...
57
                return $this->config->getFkCategoryTemplate();
58
            },
59
        ];
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    protected function getLocaleMap(): array
66
    {
67
        if (static::$localeMap === null) {
0 ignored issues
show
introduced by
The condition static::localeMap === null is always false.
Loading history...
68
            $content = file_get_contents($this->config->getLocaleMapFilePath());
69
            static::$localeMap = json_decode($content, true);
70
        }
71
72
        return static::$localeMap;
73
    }
74
}
75