Passed
Push — master ( 99427a...7e65af )
by Mike
04:46
created

CommandFinder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
4
namespace Nexus\CustomCommand\Business\Model\Finder;
5
6
7
use Symfony\Component\Finder\Finder;
8
9
class CommandFinder extends Finder implements CommandFinderInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $directory;
15
16
    /**
17
     * @var bool
18
     */
19
    private $recursive;
20
21
    /**
22
     * CommandFinder constructor.
23
     *
24
     * @param string $directory
25
     * @param bool $recursive
26
     */
27
    public function __construct(string $directory, bool $recursive)
28
    {
29
        parent::__construct();
30
31
        $this->directory = $directory;
32
        $this->recursive = $recursive;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isDir() : bool
39
    {
40
        return is_dir($this->directory);
41
    }
42
43
    /**
44
     * @return Finder
45
     */
46
    public function getCommandClasses()
47
    {
48
        if (!$this->recursive) {
49
            $this->depth('== 0');
50
        }
51
        return $this->files()->sortByName()->name('*Command.php')->in($this->directory);
52
    }
53
}