@@ -36,7 +36,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | if (!$this->isConnected()) { |
135 | 135 | throw new Exception('No open connection was found to write commands to.'); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param IrcMessage $message The message received from the server. |
154 | 154 | */ |
155 | - private function handleMessage(IrcMessage $message): void |
|
155 | + private function handleMessage (IrcMessage $message): void |
|
156 | 156 | { |
157 | 157 | $this->eventHandlerCollection->invoke(new Event('data', [$message])); |
158 | 158 | } |