Completed
Push — master ( e5efba...5eb024 )
by Ivan
19:40
created

Send   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 25.76 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 17
loc 66
rs 10
c 0
b 0
f 0
ccs 0
cts 30
cp 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A items() 0 9 1
A mail() 8 8 1
A message() 0 4 1
A money() 9 9 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 namespace FreedomCore\TrinityCore\Console\Commands;
2
3
use FreedomCore\TrinityCore\Console\Abstracts\BaseCommand;
4
use FreedomCore\TrinityCore\Console\Classes\Items;
5
6
/**
7
 * Class Send
8
 * @package FreedomCore\TrinityCore\Console\Commands
9
 */
10
class Send extends BaseCommand
11
{
12
13
    /**
14
     * Send Items To The Player
15
     * @param string $playerName
16
     * @param string $mailSubject
17
     * @param string $mailText
18
     * @param Items $items
19
     * @return array|string
20
     */
21
    public function items(string $playerName, string $mailSubject, string $mailText, Items $items)
22
    {
23
        return $this->executeCommand(__FUNCTION__, [
24
            'playerName'    =>  $playerName,
25
            'mailSubject'   =>  $this->inQuotes($mailSubject),
26
            'mailText'      =>  $this->inQuotes($mailText),
27
            'items'         =>  $items->toCommandAttribute()
28
        ]);
29
    }
30
31
    /**
32
     * Send mail to the player
33
     * @param string $playerName
34
     * @param string $mailSubject
35
     * @param string $mailText
36
     * @return array|string
37
     */
38 View Code Duplication
    public function mail(string $playerName, string $mailSubject, string $mailText)
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...
39
    {
40
        return $this->executeCommand(__FUNCTION__, [
41
            'playerName'    =>  $playerName,
42
            'mailSubject'   =>  $this->inQuotes($mailSubject),
43
            'mailText'      =>  $this->inQuotes($mailText)
44
        ]);
45
    }
46
47
    /**
48
     * Send message to the player which will appear in the middle of the screen
49
     * @param string $playerName
50
     * @param string $message
51
     * @return array|string
52
     */
53
    public function message(string $playerName, string $message)
54
    {
55
        return $this->executeCommand(__FUNCTION__, get_defined_vars());
56
    }
57
58
    /**
59
     * Send money to the player
60
     * @param string $playerName
61
     * @param string $mailSubject
62
     * @param string $mailText
63
     * @param int $amount
64
     * @return array|string
65
     */
66 View Code Duplication
    public function money(string $playerName, string $mailSubject, string $mailText, int $amount)
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...
67
    {
68
        return $this->executeCommand(__FUNCTION__, [
69
            'playerName'    =>  $playerName,
70
            'mailSubject'   =>  $this->inQuotes($mailSubject),
71
            'mailText'      =>  $this->inQuotes($mailText),
72
            'amount'        =>  $amount
73
        ]);
74
    }
75
}
76