Completed
Pull Request — master (#9)
by Adam
11:38
created

AurynCommandFactory::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Equip\Queue\Command;
4
5
use Auryn\Injector;
6
use Equip\Command\CommandInterface;
7
use Equip\Queue\Exception\CommandException;
8
9
class AurynCommandFactory implements CommandFactoryInterface
10
{
11
    /**
12
     * @var Injector
13
     */
14
    private $injector;
15
16 2
    public function __construct(Injector $injector)
17
    {
18 2
        $this->injector = $injector;
19 2
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24 2
    public function make($command)
25
    {
26 2
        $command = $this->injector->make($command);
27
28 2
        if (!is_a($command, CommandInterface::class)) {
29 1
            throw CommandException::invalidCommand($command);
30
        }
31
32 1
        return $command;
33
    }
34
}
35