Passed
Push — master ( e4cb94...6c843c )
by Jakub
02:09
created
src/ChatCommandsProcessor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.