Add::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 10
cp 0
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\Maps\ChatCommand;
4
5
use eXpansion\Bundle\Maps\Plugins\ManiaExchange;
6
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
7
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
11
/**
12
 *
13
 * @author  Reaby
14
 *
15
 */
16
class Add extends AbstractAdminChatCommand
17
{
18
19
    /** @var  ManiaExchange */
20
    protected $plugin;
21
22
    public function __construct(
23
        $command,
24
        $permission,
25
        $aliases = [],
26
        AdminGroups $adminGroupsHelper,
27
        ManiaExchange $plugin
28
    ) {
29
        parent::__construct($command, $permission, $aliases, $adminGroupsHelper);
30
        $this->plugin = $plugin;
31
    }
32
33
34
    public function getDescription()
35
    {
36
        return 'expansion_mx.command.add.help';
37
    }
38
39
    protected function configure()
40
    {
41
        parent::configure();
42
43
        $this->inputDefinition->addArgument(
44
            new InputArgument('mxid', InputArgument::REQUIRED, 'expansion_mx.command.add.mxid')
45
        );
46
47
        $this->inputDefinition->addArgument(
48
            new InputArgument('site', InputArgument::OPTIONAL, 'expansion_mx.command.add.site')
49
        );
50
51
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function execute($login, InputInterface $input)
58
    {
59
        $site = $input->getArgument('site');
60
        if (!$input->getArgument('site')) {
61
            $site = null;
62
        }
63
64
        $id = $input->getArgument('mxid');
65
66
        $this->plugin->addMap($login, $id, $site);
67
    }
68
69
}
70
71
72