Passed
Push — master ( f5488c...539e01 )
by Jeroen
01:53
created
src/IrcMessageParser.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      *
22 22
      *  @return Generator|IrcMessage[]
23 23
      */
24
-    public function parse(string $message)
24
+    public function parse (string $message)
25 25
     {
26 26
         foreach (explode("\n", $message) as $msg) {
27 27
             if (empty(trim($msg))) {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      *  @return IrcMessage
41 41
      */
42
-    private function parseSingle(string $message): IrcMessage
42
+    private function parseSingle (string $message): IrcMessage
43 43
     {
44 44
         switch ($this->getCommand($message)) {
45 45
             case 'KICK':
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      *
87 87
      *  @return string
88 88
      */
89
-    private function getCommand(string $message): string
89
+    private function getCommand (string $message): string
90 90
     {
91 91
         if ($message[0] === ':') {
92 92
             $message = trim(strstr($message, ' '));
Please login to merge, or discard this patch.
src/Options/ClientOptions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      *  @param string $nickname The nickname used on the irc server.
44 44
      *  @param string|string[] $channels The channels to join on connection.
45 45
      */
46
-    public function __construct(?string $nickname = null, $channels = [])
46
+    public function __construct (?string $nickname = null, $channels = [])
47 47
     {
48 48
         $this->nickname = $nickname;
49 49
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      *
62 62
      *  @return ConnectionOptions
63 63
      */
64
-    public function connectionOptions(): ConnectionOptions
64
+    public function connectionOptions (): ConnectionOptions
65 65
     {
66 66
         $options = new ConnectionOptions();
67 67
         $options->floodProtectionDelay = $this->floodProtectionDelay;
Please login to merge, or discard this patch.
src/IrcClient.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *  @param string $server The server address to connect to including the port: `address:port`.
34 34
      *  @param ClientOptions $options An object depicting options for this connection.
35 35
      */
36
-    public function __construct(string $server, ?ClientOptions $options = null)
36
+    public function __construct (string $server, ?ClientOptions $options = null)
37 37
     {
38 38
         $this->options = $options ?? new ClientOptions();
39 39
         $this->connection = new IrcConnection($server, $this->options->connectionOptions());
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      *
60 60
      *  @param IrcUser|string $user The user information.
61 61
      */
62
-    public function setUser($user): void
62
+    public function setUser ($user): void
63 63
     {
64 64
         if (is_string($user)) {
65 65
             $user = new IrcUser($user);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      *
78 78
      *  @throws Exception if no user information is provided before connecting.
79 79
      */
80
-    public function connect(): void
80
+    public function connect (): void
81 81
     {
82 82
         if (!$this->user) {
83 83
             throw new Exception('A nickname must be set before connecting to an irc server.');
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         }
89 89
 
90 90
         $this->isAuthenticated = false;
91
-        $this->connection->onData(function ($msg) {
91
+        $this->connection->onData(function($msg) {
92 92
             $this->handleIrcMessage($msg);
93 93
         });
94 94
         $this->connection->open();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      *  Close the current connection, if any.
99 99
      */
100
-    public function disconnect(): void
100
+    public function disconnect (): void
101 101
     {
102 102
         $this->connection->close();
103 103
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      *  @param string $event The event to register to.
109 109
      *  @param callable $callback The callback to be execute when the event is emitted.
110 110
      */
111
-    public function on(string $event, callable $callback): void
111
+    public function on (string $event, callable $callback): void
112 112
     {
113 113
         $this->messageEventHandlers->addHandler($event, $callback);
114 114
     }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      *
119 119
      *  @param string $command The full command string to send.
120 120
      */
121
-    public function send(string $command): void
121
+    public function send (string $command): void
122 122
     {
123 123
         $this->connection->write($command);
124 124
     }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      *  @param string $target The channel or user to message.
131 131
      *  @param string $message The message to send.
132 132
      */
133
-    public function say(string $target, string $message): void
133
+    public function say (string $target, string $message): void
134 134
     {
135 135
         foreach (explode("\n", $message) as $msg) {
136 136
             $this->send("PRIVMSG $target :" . trim($msg));
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      *
143 143
      *  @param string $channel The name of the channel to join.
144 144
      */
145
-    public function join(string $channel): void
145
+    public function join (string $channel): void
146 146
     {
147 147
         $channel = $this->channelName($channel);
148 148
         $this->send("JOIN $channel");
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      *
155 155
      *  @param string $channel The name of the channel to leave.
156 156
      */
157
-    public function part(string $channel): void
157
+    public function part (string $channel): void
158 158
     {
159 159
         $channel = $this->channelName($channel);
160 160
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      *
172 172
      *  @return IrcChannel
173 173
      */
174
-    public function getChannel(string $channel): IrcChannel
174
+    public function getChannel (string $channel): IrcChannel
175 175
     {
176 176
         $channel = $this->channelName($channel);
177 177
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      *
188 188
      *  @var string
189 189
      */
190
-    public function getNickname(): string
190
+    public function getNickname (): string
191 191
     {
192 192
         return $this->user->nickname;
193 193
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      *
198 198
      *  @return IrcChannel[]
199 199
      */
200
-    public function getChannels(): array
200
+    public function getChannels (): array
201 201
     {
202 202
         return $this->channels;
203 203
     }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      *
208 208
      *  @return bool
209 209
      */
210
-    public function shouldAutoRejoin(): bool
210
+    public function shouldAutoRejoin (): bool
211 211
     {
212 212
         return $this->options->autoRejoin;
213 213
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      *
218 218
      *  @param IrcMessage $message The message object for the received line.
219 219
      */
220
-    private function handleIrcMessage(IrcMessage $message): void
220
+    private function handleIrcMessage (IrcMessage $message): void
221 221
     {
222 222
         $message->injectChannel($this->channels);
223 223
         $message->handle($this);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      *
241 241
      *  @return string The formatted name.
242 242
      */
243
-    private function channelName(string $channel): string
243
+    private function channelName (string $channel): string
244 244
     {
245 245
         if ($channel[0] !== '#') {
246 246
             $channel = "#$channel";
Please login to merge, or discard this patch.
src/IrcConnection.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     /** @var string */
37 37
     private $server;
38 38
 
39
-    public function __construct(string $server, ?ConnectionOptions $options = null)
39
+    public function __construct (string $server, ?ConnectionOptions $options = null)
40 40
     {
41 41
         $options = $options ?? new ConnectionOptions();
42 42
         $this->server = $server;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $this->messageQueue = [];
50 50
 
51 51
         if ($this->floodProtected) {
52
-            $this->loop->addPeriodicTimer($options->floodProtectionDelay / 1000, function () {
52
+            $this->loop->addPeriodicTimer($options->floodProtectionDelay / 1000, function() {
53 53
                 if ($msg = array_shift($this->messageQueue)) {
54 54
                     $this->connection->write($msg);
55 55
                 }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      *  Open a connection to the irc server.
62 62
      */
63
-    public function open()
63
+    public function open ()
64 64
     {
65 65
         if ($this->isConnected()) {
66 66
             return;
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
         $dns = $dnsResolverFactory->createCached('1.1.1.1', $this->loop);
72 72
         $dnsConnector = new \React\Socket\DnsConnector($tcpConnector, $dns);
73 73
 
74
-        $dnsConnector->connect($this->server)->then(function (ConnectionInterface $connection) {
74
+        $dnsConnector->connect($this->server)->then(function(ConnectionInterface $connection) {
75 75
             $this->connection = $connection;
76 76
             $this->connected = true;
77 77
 
78
-            $this->connection->on('data', function ($data) {
78
+            $this->connection->on('data', function($data) {
79 79
                 foreach ($this->messageParser->parse($data) as $msg) {
80 80
                     $this->handleMessage($msg);
81 81
                 }
82 82
             });
83 83
 
84
-            $this->connection->on('close', function () {
84
+            $this->connection->on('close', function() {
85 85
                 $this->connected = false;
86 86
             });
87
-            $this->connection->on('end', function () {
87
+            $this->connection->on('end', function() {
88 88
                 $this->connected = false;
89 89
             });
90 90
         });
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      *  Close the current irc server connection.
97 97
      */
98
-    public function close(): void
98
+    public function close (): void
99 99
     {
100 100
         if ($this->isConnected()) {
101 101
             $this->connection->close();
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     /**
107 107
      *  Test if there is an open connection to the irc server.
108 108
      */
109
-    public function isConnected(): bool
109
+    public function isConnected (): bool
110 110
     {
111 111
         return $this->connection && $this->connected;
112 112
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      *
118 118
      *  @param callable $function The function to be called.
119 119
      */
120
-    public function onData(callable $function): void
120
+    public function onData (callable $function): void
121 121
     {
122 122
         $this->eventHandlerCollection->addHandler('data', $function);
123 123
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      *
130 130
      *  @throws Exception if no open connection is available.
131 131
      */
132
-    public function write(string $command): void
132
+    public function write (string $command): void
133 133
     {
134 134
         var_dump("OUT: $command");
135 135
         if (!$this->isConnected()) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      *
154 154
      *  @param IrcMessage $message The message received from the server.
155 155
      */
156
-    private function handleMessage(IrcMessage $message): void
156
+    private function handleMessage (IrcMessage $message): void
157 157
     {
158 158
         var_dump('IN:  ', $message);
159 159
         $this->eventHandlerCollection->invoke(new Event('data', [$message]));
Please login to merge, or discard this patch.
src/Messages/KickMessage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /** @var string */
21 21
     public $user;
22 22
 
23
-    public function __construct(string $message)
23
+    public function __construct (string $message)
24 24
     {
25 25
         parent::__construct($message);
26 26
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     /**
32 32
      *  When the bot is kicked form a channel, it might need to auto rejoin.
33 33
      */
34
-    public function handle(IrcClient $client, bool $force = false): void
34
+    public function handle (IrcClient $client, bool $force = false): void
35 35
     {
36 36
         if ($this->handled && !$force) {
37 37
             return;
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
         }
43 43
     }
44 44
 
45
-    public function getEvents(): array
45
+    public function getEvents (): array
46 46
     {
47 47
         return [
48 48
             new Event('kick', [$this->channel, $this->user, $this->message]),
49 49
         ];
50 50
     }
51 51
 
52
-    public function injectChannel(array $channels): void
52
+    public function injectChannel (array $channels): void
53 53
     {
54 54
         if (array_key_exists($this->target, $channels)) {
55 55
             $this->channel = $channels[$this->target];
Please login to merge, or discard this patch.