translate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 4
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\Communication\Plugin\TranslatorFunction;
9
10
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
0 ignored issues
show
Bug introduced by
The type Spryker\Zed\Kernel\Communication\AbstractPlugin 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...
11
use SprykerMiddleware\Zed\Process\Dependency\Plugin\TranslatorFunction\TranslatorFunctionPluginInterface;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...FunctionPluginInterface 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
/**
14
 * @method \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Communication\AkeneoPimMiddlewareConnectorCommunicationFactory getFactory()
15
 * @method \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Business\AkeneoPimMiddlewareConnectorFacadeInterface getFacade()
16
 * @method \SprykerEco\Zed\AkeneoPimMiddlewareConnector\AkeneoPimMiddlewareConnectorConfig getConfig()
17
 * @method \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Persistence\AkeneoPimMiddlewareConnectorQueryContainerInterface getQueryContainer()
18
 */
19
class AddUrlToLocalizedAttributesTranslatorFunctionPlugin extends AbstractPlugin implements TranslatorFunctionPluginInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    public const NAME = 'AddUrlToLocalizedAttributes';
25
26
    /**
27
     * @var string
28
     */
29
    public const KEY_NAME = 'name';
30
31
    /**
32
     * @var string
33
     */
34
    public const KEY_URL = 'url';
35
36
    /**
37
     * {@inheritDoc}
38
     *
39
     * @api
40
     *
41
     * @return string
42
     */
43
    public function getName(): string
44
    {
45
        return static::NAME;
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     *
51
     * @api
52
     *
53
     * @param mixed $value
54
     * @param array $payload
55
     * @param string $key
56
     * @param array $options
57
     *
58
     * @return mixed
59
     */
60
    public function translate($value, array $payload, string $key, array $options)
61
    {
62
        $translatorFunction = $this->getFactory()
63
            ->createTranslatorFunctionFactory()
64
            ->createAddUrlToLocalizedAttributesTranslatorFunction();
65
        $translatorFunction->setKey($key);
66
        $translatorFunction->setOptions($options);
67
68
        return $translatorFunction->translate($value, $payload);
69
    }
70
}
71