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

RestartMapVote   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 23.44 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 5
dl 15
loc 64
rs 10
ccs 14
cts 14
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 15 15 1
A getQuestion() 0 4 1
A executeVotePassed() 0 5 1
A executeVoteFailed() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Structures;
4
5
use eXpansion\Bundle\Maps\Services\JukeboxService;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Storage\Data\Player;
8
use eXpansion\Framework\Core\Storage\MapStorage;
9
10
/**
11
 * Class NexMapVote
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2017 Smile
15
 * @package eXpansion\Bundle\VoteManager\Structures
16
 */
17
class RestartMapVote extends AbstractVote
18
{
19
    /** @var JukeboxService */
20
    protected $jukebox;
21
22
    /** @var MapStorage */
23
    protected $mapStorage;
24
25
    /** @var ChatNotification */
26
    protected $chatNotification;
27
28
    /**
29
     * NexMapVote constructor.
30
     *
31
     * @param Player $player
32
     * @param string $type
33
     * @param int $duration
34
     * @param float $ration
35
     * @param JukeboxService $jukebox
36
     * @param MapStorage $mapStorage
37
     * @param ChatNotification $chatNotification
38
     */
39 3 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
        Player $player,
41
        string $type,
42
        int $duration = 30,
43
        float $ration = 0.57,
44
        JukeboxService $jukebox,
45
        MapStorage $mapStorage,
46
        ChatNotification $chatNotification
47
    ) {
48 3
        parent::__construct($player, $type, $duration, $ration);
49
50 3
        $this->jukebox = $jukebox;
51 3
        $this->mapStorage = $mapStorage;
52 3
        $this->chatNotification = $chatNotification;
53 3
    }
54
55
56
    /**
57
     * @inheritdoc
58
     */
59 1
    public function getQuestion(): string
60
    {
61 1
        return 'expansion_votemanager.restartmap.question';
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67 1
    public function executeVotePassed()
68
    {
69 1
        $this->jukebox->addMap($this->mapStorage->getCurrentMap(), $this->getPlayer()->getLogin(), true);
70 1
        $this->chatNotification->sendMessage("|info| Vote passed. Will replay map!");
71 1
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76 1
    public function executeVoteFailed()
77
    {
78
        // Do Nothing
79 1
    }
80
}
81