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

CommandLauncher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
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