IncorrectPlaceholderDataExecutor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A executeIncorrectPlaceholderData() 0 17 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\Yves\Coremedia\ApiResponse\Executor;
9
10
use Generated\Shared\Transfer\CoremediaPlaceholderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ediaPlaceholderTransfer 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 Spryker\Shared\ErrorHandler\ErrorLogger;
12
use SprykerEco\Yves\Coremedia\CoremediaConfig;
13
use SprykerEco\Yves\Coremedia\Exception\InvalidPlaceholderDataException;
14
15
class IncorrectPlaceholderDataExecutor implements IncorrectPlaceholderDataExecutorInterface
16
{
17
    /**
18
     * @var \SprykerEco\Yves\Coremedia\CoremediaConfig
19
     */
20
    protected $config;
21
22
    /**
23
     * @param \SprykerEco\Yves\Coremedia\CoremediaConfig $coreMediaConfig
24
     */
25
    public function __construct(CoremediaConfig $coreMediaConfig)
26
    {
27
        $this->config = $coreMediaConfig;
28
    }
29
30
    /**
31
     * @param \Generated\Shared\Transfer\CoremediaPlaceholderTransfer $coreMediaPlaceholderTransfer
32
     * @param string $locale
33
     *
34
     * @return void
35
     */
36
    public function executeIncorrectPlaceholderData(
37
        CoremediaPlaceholderTransfer $coreMediaPlaceholderTransfer,
38
        string $locale
39
    ): void {
40
        if (!$this->config->isDebugModeEnabled()) {
41
            return;
42
        }
43
44
        $dataException = new InvalidPlaceholderDataException(
45
            sprintf(
46
                "Cannot obtain placeholder replacement for:\n[Placeholder]: %s\n[Locale]: %s",
47
                $coreMediaPlaceholderTransfer->getPlaceholderBody(),
48
                $locale
49
            )
50
        );
51
52
        ErrorLogger::getInstance()->log($dataException);
53
    }
54
}
55