Completed
Pull Request — master (#9)
by Adam
04:10 queued 01:38
created

SimpleCommandFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 17
ccs 0
cts 11
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 14 3
1
<?php
2
3
namespace Equip\Queue\Command;
4
5
use Equip\Command\CommandInterface;
6
use Equip\Queue\Exception\CommandException;
7
use Equip\Queue\Exception\HandlerException;
8
9
class SimpleCommandFactory implements CommandFactoryInterface
10
{
11
    public function make($command)
12
    {
13
        if (!class_exists($command)) {
14
            throw CommandException::notFound($command);
15
        }
16
17
        $command = new $command;
18
19
        if (!($command instanceof CommandInterface)) {
20
            throw CommandException::invalidCommand($command);
0 ignored issues
show
Documentation introduced by
$command is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
        }
22
23
        return $command;
24
    }
25
}
26