Completed
Pull Request — master (#9)
by Adam
05:57
created

AurynCommandFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 30
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 14 3
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 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