ProductAbstractExistValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 7 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\Validator\Validators;
9
10
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Facade\AkeneoPimMiddlewareConnectorToProductFacadeBridgeInterface;
11
use SprykerMiddleware\Zed\Process\Business\Validator\Validators\AbstractValidator;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...ators\AbstractValidator 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 ProductAbstractExistValidator extends AbstractValidator
14
{
15
    /**
16
     * @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Facade\AkeneoPimMiddlewareConnectorToProductFacadeBridgeInterface
17
     */
18
    protected $productFacade;
19
20
    /**
21
     * @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Facade\AkeneoPimMiddlewareConnectorToProductFacadeBridgeInterface $productFacade
22
     */
23
    public function __construct(AkeneoPimMiddlewareConnectorToProductFacadeBridgeInterface $productFacade)
24
    {
25
        $this->productFacade = $productFacade;
26
    }
27
28
    /**
29
     * @param mixed $value
30
     * @param array $payload
31
     *
32
     * @return bool
33
     */
34
    public function validate($value, array $payload): bool
35
    {
36
        if ($value == null) {
37
            return true;
38
        }
39
40
        return (bool)$this->productFacade->findProductAbstractIdBySku($value);
41
    }
42
}
43