Filters::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Ionut\Sylar;
4
5
6
use Ionut\Sylar\Filters\FilterReportInterface;
7
8
class Filters
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $items;
14
15
    /**
16
     * @param array $items
17
     */
18
    public function __construct(array $items)
19
    {
20
        $this->items = $items;
21
    }
22
23
    /**
24
     * @param  NormalizedValue  $normalizedValue
25
     * @return Filters\FilterReportInterface[]
26
     */
27
    public function matches(NormalizedValue $normalizedValue)
28
    {
29
        foreach ($this->items as $item) {
30
            foreach ($normalizedValue->getVariantsWithOriginal() as $variant) {
31
                if ($filterReport = $item->matches($variant)) {
32
                    yield $filterReport;
33
                    break;
34
                }
35
            }
36
        }
37
    }
38
}