ValidateSkipper::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 2
b 0
f 0
nc 3
nop 2
dl 0
loc 9
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\DeferJs\Model\PassesValidator;
11
12
use Magento\Framework\App\Response\Http;
13
14
/**
15
 * Class Validate
16
 */
17
class ValidateSkipper
18
{
19
    /**
20
     * @var EntityList
21
     */
22
    private $deferJsPassesValidators;
23
24
    /**
25
     * Validate constructor.
26
     *
27
     * @param EntityList $deferJsPassesValidators
28
     */
29
    public function __construct(
30
        EntityList $deferJsPassesValidators
31
    ) {
32
        $this->deferJsPassesValidators = $deferJsPassesValidators;
33
    }
34
35
    /**
36
     * @param string $script
37
     * @param Http $http
38
     *
39
     * @return bool
40
     */
41
    public function execute(string $script, Http $http): bool
42
    {
43
        foreach ($this->deferJsPassesValidators->getList() as $deferJsPassesValidator) {
44
            if ($deferJsPassesValidator->validate($script, $http)) {
45
                return true;
46
            }
47
        }
48
49
        return false;
50
    }
51
}
52