CriteriaBuilderCollection::getCriteriaBuilders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace KGzocha\Searcher\CriteriaBuilder\Collection;
5
6
use KGzocha\Searcher\AbstractCollection;
7
use KGzocha\Searcher\Context\SearchingContextInterface;
8
use KGzocha\Searcher\CriteriaBuilder\CriteriaBuilderInterface;
9
10
/**
11
 * @author Krzysztof Gzocha <[email protected]>
12
 */
13 View Code Duplication
class CriteriaBuilderCollection extends AbstractCollection implements CriteriaBuilderCollectionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @param CriteriaBuilderInterface[] $builders array or \Traversable object
17
     */
18 9
    public function __construct($builders = [])
19
    {
20 9
        parent::__construct($builders);
21 4
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function addCriteriaBuilder(CriteriaBuilderInterface $criteriaBuilder): CriteriaBuilderCollectionInterface
27
    {
28 1
        return $this->addItem($criteriaBuilder);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function getCriteriaBuilders()
35
    {
36 1
        return $this->getItems();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function getCriteriaBuildersForContext(
43
        SearchingContextInterface $searchingContext
44
    ): CriteriaBuilderCollectionInterface {
45 2
        return new self(array_filter(
46 2
            $this->getItems(),
47 2
            function (CriteriaBuilderInterface $criteriaBuilder) use ($searchingContext) {
48 2
                return $criteriaBuilder->supportsSearchingContext($searchingContext);
49 2
            }
50
        ));
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 3
    protected function isItemValid($item): bool
57
    {
58 3
        return $item instanceof CriteriaBuilderInterface;
59
    }
60
}
61