@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function addCommand(IChatCommand $command): void |
22 | 22 | { |
23 | 23 | $name = $command->getName(); |
24 | - if ($this->hasCommand($name)) { |
|
24 | + if($this->hasCommand($name)) { |
|
25 | 25 | throw new CommandNameAlreadyUsedException("Command $name is already defined."); |
26 | 26 | } |
27 | 27 | $this->commands[] = $command; |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function extractCommand(string $text): string |
48 | 48 | { |
49 | - if (!str_starts_with($text, "/")) { |
|
49 | + if(!str_starts_with($text, "/")) { |
|
50 | 50 | return ""; |
51 | 51 | } |
52 | - if (!str_contains($text, " ")) { |
|
52 | + if(!str_contains($text, " ")) { |
|
53 | 53 | $command = substr($text, 1); |
54 | 54 | } else { |
55 | 55 | $parts = explode(" ", substr($text, 1)); |
56 | 56 | $command = $parts[0]; |
57 | 57 | } |
58 | - if ($this->hasCommand($command)) { |
|
58 | + if($this->hasCommand($command)) { |
|
59 | 59 | return $command; |
60 | 60 | } |
61 | 61 | return ""; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function extractParameters(string $text): array |
69 | 69 | { |
70 | - if (!str_starts_with($text, "/") || !str_contains($text, " ")) { |
|
70 | + if(!str_starts_with($text, "/") || !str_contains($text, " ")) { |
|
71 | 71 | return []; |
72 | 72 | } |
73 | 73 | $params = explode(" ", $text); |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function hasCommand(string $name): bool |
82 | 82 | { |
83 | - foreach ($this->commands as $command) { |
|
84 | - if ($command->getName() === $name) { |
|
83 | + foreach($this->commands as $command) { |
|
84 | + if($command->getName() === $name) { |
|
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getCommand(string $name): IChatCommand |
97 | 97 | { |
98 | - foreach ($this->commands as $command) { |
|
99 | - if ($command->getName() === $name) { |
|
98 | + foreach($this->commands as $command) { |
|
99 | + if($command->getName() === $name) { |
|
100 | 100 | return $command; |
101 | 101 | } |
102 | 102 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function parse(string $message): ?string |
107 | 107 | { |
108 | 108 | $commandName = $this->extractCommand($message); |
109 | - if ($commandName === "") { |
|
109 | + if($commandName === "") { |
|
110 | 110 | return null; |
111 | 111 | } |
112 | 112 | $command = $this->getCommand($commandName); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $name = $command->getName(); |
24 | 24 | if ($this->hasCommand($name)) { |
25 | - throw new CommandNameAlreadyUsedException("Command $name is already defined."); |
|
25 | + throw new CommandNameAlreadyUsedException("command $name is already defined."); |
|
26 | 26 | } |
27 | 27 | $this->commands[] = $command; |
28 | 28 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return $command; |
101 | 101 | } |
102 | 102 | } |
103 | - throw new CommandNotFoundException("Command $name is not defined."); |
|
103 | + throw new CommandNotFoundException("command $name is not defined."); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | public function parse(string $message): ?string |