Completed
Pull Request — master (#9)
by Adam
05:10 queued 02:21
created

AurynCommandFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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
10
{
11
    /**
12
     * @var Injector
13
     */
14
    private $injector;
15
16 3
    public function __construct(Injector $injector)
17
    {
18 3
        $this->injector = $injector;
19 3
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24 3
    public function make($command)
25
    {
26 3
        if (!class_exists($command)) {
27 1
            throw CommandException::notFound($command);
28
        }
29
30 2
        $command = $this->injector->make($command);
31
32 2
        if (!($command instanceof CommandInterface)) {
33 1
            throw CommandException::invalidCommand($command);
34
        }
35
36 1
        return $command;
37
    }
38
}
39