Completed
Push — master ( d64c29...1f74a2 )
by Kamil
02:10
created

ExcludingSpecificationIterator::accept()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ExcludeSpecificationsExtension package.
7
 *
8
 * (c) Kamil Kokot <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace FriendsOfBehat\ExcludeSpecificationsExtension\Locator;
15
16
use Behat\Testwork\Specification\SpecificationIterator;
17
use Behat\Testwork\Suite\Suite;
18
19
/**
20
 * @internal
21
 */
22
final class ExcludingSpecificationIterator extends \FilterIterator implements SpecificationIterator
23
{
24
    /**
25
     * @var SpecificationIterator
26
     */
27
    private $specificationIterator;
28
29
    /**
30
     * @var array
31
     */
32
    private $skippedPaths;
33
34
    /**
35
     * @param SpecificationIterator $specificationIterator
36
     * @param array $skippedPaths
37
     */
38
    public function __construct(SpecificationIterator $specificationIterator, array $skippedPaths)
39
    {
40
        parent::__construct($specificationIterator);
41
42
        $this->specificationIterator = $specificationIterator;
43
        $this->skippedPaths = $skippedPaths;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function accept(): bool
50
    {
51
        return !in_array(
52
            $this->current()->getFile(),
53
            $this->skippedPaths,
54
            true
55
        );
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function getSuite(): Suite
62
    {
63
        return $this->specificationIterator->getSuite();
64
    }
65
}
66