GetCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

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