NextMapVote::executeVoteFailed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Plugins\Votes;
4
5
use eXpansion\Framework\Core\Helpers\ChatNotification;
6
use eXpansion\Framework\Core\Services\Application\DispatcherInterface;
7
use eXpansion\Framework\Core\Services\DedicatedConnection\Factory;
8
use eXpansion\Framework\Core\Storage\PlayerStorage;
9
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpScriptPodium;
10
use Maniaplanet\DedicatedServer\Connection;
11
12
/**
13
 * Class NextMapVote
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 eXpansion
17
 * @package eXpansion\Bundle\VoteManager\Plugins\Votes
18
 */
19
class NextMapVote extends AbstractVotePlugin implements ListenerInterfaceMpScriptPodium
20
{
21
    /** @var Factory */
22
    protected $factory;
23
24
    /** @var ChatNotification */
25
    protected $chatNotification;
26
27
    /**
28
     * NextMapVote constructor.
29
     *
30
     * @param PlayerStorage $playerStorage
31
     * @param Factory $factory
32
     * @param ChatNotification $chatNotification
33
     * @param int $duration
34
     * @param float $ratio
35
     */
36 7
    public function __construct(
37
        DispatcherInterface $dispatcher,
38
        PlayerStorage $playerStorage,
39
        Factory $factory,
40
        ChatNotification $chatNotification,
41
        int $duration,
42
        float $ratio
43
    ) {
44 7
        parent::__construct($dispatcher, $playerStorage, $duration, $ratio);
45
46 7
        $this->factory = $factory;
47 7
        $this->chatNotification = $chatNotification;
48 7
    }
49
50
51
    /**
52
     * @inheritdoc
53
     */
54 1
    public function getQuestion(): string
55
    {
56 1
        return 'expansion_votemanager.nextmap.question';
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 2
    protected function executeVotePassed()
63
    {
64 2
        $this->factory->getConnection()->nextMap(false);
65 2
        $this->chatNotification->sendMessage("|info| Vote passed. Skipping map!");
66 2
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71 1
    protected function executeVoteFailed()
72
    {
73
        // Do Nothing
74 1
    }
75
76
    /**
77
     * Get type code of this vote.
78
     *
79
     * @return string
80
     */
81 6
    public function getCode(): string
82
    {
83 6
        return 'Exp_NextMap';
84
    }
85
86
    /**
87
     * Get native votes this votes replaces.
88
     *
89
     * @return string[]
90
     */
91 1
    public function getReplacementTypes(): array
92
    {
93 1
        return ['NextMap'];
94
    }
95
96
    /**
97
     * Callback sent when the "onPodiumStart" section start.
98
     *
99
     * @param int $time Server time when the callback was sent
100
     * @return void
101
     */
102
    public function onPodiumStart($time)
103
    {
104
        //nothing
105
    }
106
107
    /**
108
     * Callback sent when the "onPodiumEnd" section end.
109
     *
110
     * @param int $time Server time when the callback was sent
111
     *
112
     * @return void
113
     */
114
    public function onPodiumEnd($time)
115
    {
116
        $this->cancel();
117
    }
118
}
119