Completed
Push — master ( 42a15b...d491ac )
by Paweł
02:03
created

CommandLauncher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCommandReflection() 0 4 1
A getCommandToLaunch() 0 6 1
1
<?php
2
3
namespace Clearcode\CommandBusConsole;
4
5
class CommandLauncher
6
{
7
    /** @var CommandCollector */
8
    private $commandCollector;
9
    /** @var ArgumentsProcessor */
10
    private $argumentsProcessor;
11
12
    /**
13
     * @param CommandCollector   $commandCollector
14
     * @param ArgumentsProcessor $argumentsProcessor
15
     */
16
    public function __construct(CommandCollector $commandCollector, ArgumentsProcessor $argumentsProcessor)
17
    {
18
        $this->commandCollector = $commandCollector;
19
        $this->argumentsProcessor = $argumentsProcessor;
20
    }
21
22
    /**
23
     * @param $commandName
24
     *
25
     * @return CommandReflection
26
     *
27
     * @throws CommandDoesNotExist
28
     */
29
    public function getCommandReflection($commandName)
30
    {
31
        return $this->commandCollector->getCommandByName($commandName);
32
    }
33
34
    /**
35
     * @param $commandName
36
     * @param $arguments
37
     *
38
     * @return object
39
     *
40
     * @throws CommandDoesNotExist
41
     */
42
    public function getCommandToLaunch($commandName, $arguments)
43
    {
44
        $commandReflection = $this->commandCollector->getCommandByName($commandName);
45
46
        return $commandReflection->createCommand($arguments, $this->argumentsProcessor);
47
    }
48
}
49