DefinitionFinder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 11
c 1
b 0
f 1
dl 0
loc 37
rs 10

2 Methods

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