Completed
Push — master ( 78d6cc...47a555 )
by Paweł
17:34 queued 17:12
created

ProductFilter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 15 4
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Component\Core\Promotion\Filter;
13
14
/**
15
 * @author Łukasz Chruściel <[email protected]>
16
 */
17
final class ProductFilter implements FilterInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function filter(array $items, array $configuration)
23
    {
24
        if (!isset($configuration['filters']['products_filter'])) {
25
            return $items;
26
        }
27
28
        $filteredItems = [];
29
        foreach ($items as $item) {
30
            if (in_array($item->getProduct()->getCode(), $configuration['filters']['products_filter']['products'], true)) {
31
                $filteredItems[] = $item;
32
            }
33
        }
34
35
        return $filteredItems;
36
    }
37
}
38