Passed
Push — master ( c74e22...4ec3b5 )
by Volodymyr
04:11
created

ValidateSkipper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 Hryvinskyi\Base\Helper\VarDumper;
13
use Magento\Framework\App\Response\Http;
14
15
/**
16
 * Class Validate
17
 */
18
class ValidateSkipper
19
{
20
    /**
21
     * @var EntityList
22
     */
23
    private $deferJsPassesValidators;
24
25
    /**
26
     * Validate constructor.
27
     *
28
     * @param EntityList $deferJsPassesValidators
29
     */
30
    public function __construct(
31
        EntityList $deferJsPassesValidators
32
    ) {
33
        $this->deferJsPassesValidators = $deferJsPassesValidators;
34
    }
35
36
    /**
37
     * @param string $script
38
     * @param Http $http
39
     *
40
     * @return bool
41
     */
42
    public function execute(string $script, Http $http): bool
43
    {
44
        foreach ($this->deferJsPassesValidators->getList() as $deferJsPassesValidator) {
45
            if($deferJsPassesValidator->validate($script, $http)) {
46
                return true;
47
            }
48
        }
49
50
        return false;
51
    }
52
}