|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\Emotes\ChatCommand; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Core\Helpers\ChatNotification; |
|
6
|
|
|
use eXpansion\Core\Model\ChatCommand\AbstractChatCommand; |
|
7
|
|
|
use eXpansion\Core\Storage\PlayerStorage; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class BasicEmote to handle basic emote chat oommands. |
|
12
|
|
|
* |
|
13
|
|
|
* @package eXpansion\Bundle\Emotes\ChatCommand; |
|
14
|
|
|
* @author oliver de Cramer <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class BasicEmote extends AbstractChatCommand |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var string[] */ |
|
19
|
|
|
protected $messages; |
|
20
|
|
|
|
|
21
|
|
|
/** @var ChatNotification */ |
|
22
|
|
|
protected $chatNotification; |
|
23
|
|
|
|
|
24
|
|
|
/** @var PlayerStorage */ |
|
25
|
|
|
protected $playerStorage; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* BasicEmote constructor. |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $command The chat command |
|
31
|
|
|
* @param string $message The emote message to send |
|
|
|
|
|
|
32
|
|
|
* @param ChatNotification $chatNotification |
|
33
|
|
|
* @param array $aliases |
|
34
|
|
|
* @param bool $parametersAsArray |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct( |
|
37
|
|
|
$command, |
|
38
|
|
|
$nbMessages, |
|
39
|
|
|
array $aliases = [], |
|
40
|
|
|
ChatNotification $chatNotification, |
|
41
|
|
|
PlayerStorage $playerStorage, |
|
42
|
|
|
$parametersAsArray = true |
|
43
|
|
|
) { |
|
44
|
|
|
parent::__construct($command, $aliases, $parametersAsArray); |
|
45
|
|
|
$this->chatNotification = $chatNotification; |
|
46
|
|
|
$this->playerStorage = $playerStorage; |
|
47
|
|
|
|
|
48
|
|
|
for($i = 1; $i <= $nbMessages; $i++) { |
|
49
|
|
|
$this->messages[] = "expansion_emotes.$command" . $i; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function execute($login, $parameter) |
|
54
|
|
|
{ |
|
55
|
|
|
$select = rand(0, count($this->messages) - 1); |
|
56
|
|
|
$message = $this->messages[$select]; |
|
57
|
|
|
|
|
58
|
|
|
$nickName = $this->playerStorage->getPlayerInfo($login)->getNickName(); |
|
59
|
|
|
$this->chatNotification->sendMessage($message, null, ['%nickname%' => $nickName]); |
|
60
|
|
|
} |
|
61
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.