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

CommandHydrator::getCommandsFromFinder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
4
namespace Nexus\CustomCommand\Business\Hydrator;
5
6
7
use Nexus\CustomCommand\Business\Finder\CommandFinderInterface;
8
9
class CommandHydrator implements CommandHydratorInterface
10
{
11
    /**
12
     * @var \Nexus\CustomCommand\Business\Finder\CommandFinderInterface
13
     */
14
    private $commandFinder;
15
16
    /**
17
     * CommandHydrator constructor.
18
     *
19
     * @param \Nexus\CustomCommand\Business\Finder\CommandFinderInterface $commandFinder
20
     */
21 3
    public function __construct(CommandFinderInterface $commandFinder)
22
    {
23 3
        $this->commandFinder = $commandFinder;
24 3
    }
25
26
    /**
27
     * @param array $commands
28
     *
29
     * @return array
30
     */
31 3
    public function hydrateCommands(array $commands)
32
    {
33 3
        if ($this->commandFinder->isDir()) {
34 2
            $commands += $this->getCommandsFromFinder();
35
        }
36
37 3
        return $commands;
38
    }
39
40
    /**
41
     * @param array $commands
0 ignored issues
show
Bug introduced by
There is no parameter named $commands. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
42
     *
43
     * @return array
44
     */
45 2
    private function getCommandsFromFinder(): array
46
    {
47 2
        $commands = [];
48 2
        foreach ($this->commandFinder->getCommandClasses() as $file) {
49 2
            require_once $file->getRealPath();
50
51 2
            $className = sprintf(
52 2
                'Nexus\\CustomCommand\\Command\\%s',
53 2
                $file->getBasename('.php')
54
            );
55 2
            $commands[] = new $className();
56
        }
57 2
        return $commands;
58
    }
59
60
61
}