Passed
Pull Request — master (#16)
by Daniel
02:13
created

DefinitionFinder::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Jellyfish\Transfer\Definition;
4
5
use Iterator;
6
use Jellyfish\Finder\FinderFactoryInterface;
7
8
class DefinitionFinder implements DefinitionFinderInterface
9
{
10
    protected const IN_PATTERN = '{,vendor/*/*/}src/*/*/Transfer/';
11
    protected const NAME_PATTERN = '*.transfer.json';
12
13
    /**
14
     * @var string
15
     */
16
    protected $rootDir;
17
18
    /**
19
     * @var \Jellyfish\Finder\FinderFactoryInterface
20
     */
21
    protected $finderFactory;
22
23
    /**
24
     * @param \Jellyfish\Finder\FinderFactoryInterface $finderFactory
25
     * @param string $rootDir
26
     */
27
    public function __construct(
28
        FinderFactoryInterface $finderFactory,
29
        string $rootDir
30
    ) {
31
        $this->rootDir = $rootDir;
32
        $this->finderFactory = $finderFactory;
33
    }
34
35
    /**
36
     * @return \Iterator
37
     */
38
    public function find(): Iterator
39
    {
40
        $finder = $this->finderFactory->create();
41
42
        return $finder->in(static::IN_PATTERN)
43
            ->name(static::NAME_PATTERN)
44
            ->getIterator();
45
    }
46
}
47