FilteringFinder.php 896 Bytes
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
9
10
11
12
 */

namespace Irstea\PlantUmlBundle\Finder;

use CallbackFilterIterator;
use Irstea\PlantUmlBundle\Model\ClassFilterInterface;

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
13
 * Description of FilteringFinder.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 */
class FilteringFinder implements FinderInterface
{
    /**
     * @var FinderInterface
     */
    private $inner;

    /**
     * @var ClassFilterInterface
     */
    private $filter;

    public function __construct(FinderInterface $inner, ClassFilterInterface $filter)
    {
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
29
        $this->inner = $inner;
30
31
32
33
34
35
36
        $this->filter = $filter;
    }

    public function getIterator()
    {
        return new CallbackFilterIterator($this->inner->getIterator(), [$this->filter, 'accept']);
    }
37
38
39
40
41
42

    public function toConfig(array &$conf)
    {
        $this->inner->toConfig($conf);
        $this->filter->toConfig($conf);
    }
43
}