Completed
Push — master ( 47c10a...c931cd )
by De Cramer
13s
created

RestartMapVote   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 81
rs 10
c 0
b 0
f 0
ccs 18
cts 18
cp 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A getQuestion() 0 4 1
A executeVotePassed() 0 5 1
A executeVoteFailed() 0 4 1
A getCode() 0 4 1
A getReplacementTypes() 0 4 1
1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Plugins\Votes;
4
5
use eXpansion\Bundle\Maps\Services\JukeboxService;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Storage\MapStorage;
8
use eXpansion\Framework\Core\Storage\PlayerStorage;
9
10
/**
11
 * Class NextMapVote
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2017 eXpansion
15
 * @package eXpansion\Bundle\VoteManager\Plugins\Votes
16
 */
17
class RestartMapVote extends AbstractVotePlugin
18
{
19
    /** @var JukeboxService */
20
    protected $jukebox;
21
22
    /** @var MapStorage */
23
    protected $mapStorage;
24
25
    /** @var ChatNotification */
26
    protected $chatNotification;
27
28
    /**
29
     * RestartMapVote constructor.
30
     *
31
     * @param PlayerStorage $playerStorage
32
     * @param JukeboxService $jukebox
33
     * @param MapStorage $mapStorage
34
     * @param ChatNotification $chatNotification
35
     * @param int $duration
36
     * @param float $ratio
37
     */
38 3
    public function __construct(
39
        PlayerStorage $playerStorage,
40
        JukeboxService $jukebox,
41
        MapStorage $mapStorage,
42
        ChatNotification $chatNotification,
43
        int $duration,
44
        float $ratio
45
    ) {
46 3
        parent::__construct($playerStorage, $duration, $ratio);
47
48 3
        $this->jukebox = $jukebox;
49 3
        $this->mapStorage = $mapStorage;
50 3
        $this->chatNotification = $chatNotification;
51 3
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56 1
    public function getQuestion(): string
57
    {
58 1
        return 'expansion_votemanager.restartmap.question';
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64 1
    public function executeVotePassed()
65
    {
66 1
        $this->jukebox->addMap($this->mapStorage->getCurrentMap(), $this->getCurrentVote()->getPlayer()->getLogin(), true);
67 1
        $this->chatNotification->sendMessage("|info| Vote passed. Will replay map!");
68 1
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 1
    protected function executeVoteFailed()
74
    {
75
        // Do Nothing
76 1
    }
77
78
    /**
79
     * Get type code of this vote.
80
     *
81
     * @return string
82
     */
83 3
    public function getCode(): string
84
    {
85 3
        return 'Exp_RestartMap';
86
    }
87
88
    /**
89
     * Get native votes this votes replaces.
90
     *
91
     * @return string[]
92
     */
93 1
    public function getReplacementTypes(): array
94
    {
95 1
        return ['RestartMap'];
96
    }
97
}
98