Test Failed
Push — master ( fdad3b...1a9d53 )
by Mike
07:27
created

CommandFinder::getCommandClasses()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
4
namespace Nexus\CustomCommand\Business\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 3
    public function __construct(string $directory, bool $recursive)
28
    {
29 3
        parent::__construct();
30
31 3
        $this->directory = $directory;
32 3
        $this->recursive = $recursive;
33 3
    }
34
35
    /**
36
     * @return bool
37
     */
38 3
    public function isDir() : bool
39
    {
40 3
        return is_dir($this->directory);
41
    }
42
43
    /**
44
     * @return Finder
45
     */
46 2
    public function getCommandClasses()
47
    {
48 2
        if (!$this->recursive) {
49 1
            $this->depth('== 0');
50
        }
51 2
        return $this->files()->name('*Command.php')->in($this->directory);
52
    }
53
}