GetCommand::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace HotRodCli\Api;
4
5
use HotRodCli\AppContainer;
6
use HotRodCli\Commands\BaseCommand;
7
8
class GetCommand extends GetCommands
9
{
10
    protected $commands;
11
12
    public function __construct(AppContainer $appContainer)
13
    {
14
        parent::__construct($appContainer);
15
        $this->commands = $this->container->resolve('commands');
16
    }
17
18
    public function __invoke($args = [])
19
    {
20
        /** @var BaseCommand $command */
21
        $command = $this->container->resolve($this->commands[$args['command']]);
22
23
        return json_encode([
24
            'name' => $command->getName(),
25
            'description' => $command->getDescription(),
26
            'help' => $command->getHelp(),
27
            'arguments' => $this->constructArguments($command),
28
            'options' => $this->constructOptions($command)
29
        ]);
30
    }
31
}
32