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

NextMapVote   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 76
rs 10
c 0
b 0
f 0
ccs 17
cts 17
cp 1

6 Methods

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