Completed
Pull Request — master (#154)
by De Cramer
02:58
created

AdminVoteCommand::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0
ccs 0
cts 14
cp 0
cc 1
eloc 24
nc 1
nop 11
crap 2

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace eXpansion\Bundle\AdminChat\ChatCommand;
4
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Helpers\Time;
8
use eXpansion\Framework\Core\Services\Application\Dispatcher;
9
use eXpansion\Framework\Core\Storage\PlayerStorage;
10
use Maniaplanet\DedicatedServer\Connection;
11
use Psr\Log\LoggerInterface;
12
use Symfony\Component\Console\Input\InputInterface;
13
14
/**
15
 * Class ReasonUserCommand
16
 *
17
 * @author  Reaby
18
 * @package eXpansion\Bundle\AdminChat\ChatCommand
19
 */
20
class AdminVoteCommand extends AdminCommand
21
{
22
    /**
23
     * @var Dispatcher
24
     */
25
    private $dispatcher;
26
27
    /**
28
     * AdminCommand constructor.
29
     *
30
     * @param $command
31
     * @param string $permission
32
     * @param array $aliases
33
     * @param ChatNotification $functionName
34
     * @param AdminGroups $adminGroupsHelper
35
     * @param Connection $connection
36
     * @param ChatNotification $chatNotification
37
     * @param PlayerStorage $playerStorage
38
     * @param LoggerInterface $logger
39
     * @param Time $timeHelper
40
     * @param Dispatcher $dispatcher
41
     */
42
    public function __construct(
43
        $command,
44
        $permission,
45
        array $aliases = [],
46
        $functionName,
47
        AdminGroups $adminGroupsHelper,
48
        Connection $connection,
49
        ChatNotification $chatNotification,
50
        PlayerStorage $playerStorage,
51
        LoggerInterface $logger,
52
        Time $timeHelper,
53
        Dispatcher $dispatcher
54
    ) {
55
        parent::__construct(
56
            $command,
57
            $permission,
58
            $aliases = [],
59
            $functionName,
60
            $adminGroupsHelper,
61
            $connection,
62
            $chatNotification,
63
            $playerStorage,
64
            $logger,
65
            $timeHelper
66
        );
67
68
        $this->dispatcher = $dispatcher;
69
    }
70
71
    /**
72
     * @inheritdoc
73
     */
74
    public function execute($login, InputInterface $input)
75
    {
76
        parent::execute($login, $input);
77
        $player = $this->playerStorage->getPlayerInfo($login);
78
        $this->dispatcher->dispatch("votemanager.votecancelled", [$player, null, null]);
79
    }
80
}
81