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

CommandHydrator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 53
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hydrateCommands() 0 8 2
A getCommandsFromFinder() 0 14 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
}