@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** @var string[] */ |
| 14 | 14 | private $users; |
| 15 | 15 | |
| 16 | - public function __construct(string $name) |
|
| 16 | + public function __construct (string $name) |
|
| 17 | 17 | { |
| 18 | 18 | if ($name[0] !== '#') { |
| 19 | 19 | $name = "#$name"; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public function getName(): string |
|
| 30 | + public function getName (): string |
|
| 31 | 31 | { |
| 32 | 32 | return $this->name; |
| 33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return null|string |
| 39 | 39 | */ |
| 40 | - public function getTopic() |
|
| 40 | + public function getTopic () |
|
| 41 | 41 | { |
| 42 | 42 | return $this->topic; |
| 43 | 43 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return string[] |
| 49 | 49 | */ |
| 50 | - public function getUsers(): array |
|
| 50 | + public function getUsers (): array |
|
| 51 | 51 | { |
| 52 | 52 | return $this->users; |
| 53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param string $topic The topic |
| 59 | 59 | */ |
| 60 | - public function setTopic(string $topic): void |
|
| 60 | + public function setTopic (string $topic): void |
|
| 61 | 61 | { |
| 62 | 62 | $this->topic = $topic; |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string[] $users An array of user names. |
| 69 | 69 | */ |
| 70 | - public function setUsers(array $users): void |
|
| 70 | + public function setUsers (array $users): void |
|
| 71 | 71 | { |
| 72 | 72 | $this->users = $users; |
| 73 | 73 | } |
@@ -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,27 +60,27 @@ 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 | $tcpConnector = new \React\Socket\TcpConnector($this->loop); |
| 66 | 66 | $dnsResolverFactory = new \React\Dns\Resolver\Factory(); |
| 67 | 67 | $dns = $dnsResolverFactory->createCached('1.1.1.1', $this->loop); |
| 68 | 68 | $dnsConnector = new \React\Socket\DnsConnector($tcpConnector, $dns); |
| 69 | 69 | |
| 70 | - $dnsConnector->connect($this->server)->then(function (ConnectionInterface $connection) { |
|
| 70 | + $dnsConnector->connect($this->server)->then(function(ConnectionInterface $connection) { |
|
| 71 | 71 | $this->connection = $connection; |
| 72 | 72 | $this->connected = true; |
| 73 | 73 | |
| 74 | - $this->connection->on('data', function ($data) { |
|
| 74 | + $this->connection->on('data', function($data) { |
|
| 75 | 75 | foreach ($this->messageParser->parse($data) as $msg) { |
| 76 | 76 | $this->handleMessage($msg); |
| 77 | 77 | } |
| 78 | 78 | }); |
| 79 | 79 | |
| 80 | - $this->connection->on('close', function () { |
|
| 80 | + $this->connection->on('close', function() { |
|
| 81 | 81 | $this->connected = false; |
| 82 | 82 | }); |
| 83 | - $this->connection->on('end', function () { |
|
| 83 | + $this->connection->on('end', function() { |
|
| 84 | 84 | $this->connected = false; |
| 85 | 85 | }); |
| 86 | 86 | }); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * Close the current irc server connection. |
| 93 | 93 | */ |
| 94 | - public function close(): void |
|
| 94 | + public function close (): void |
|
| 95 | 95 | { |
| 96 | 96 | if ($this->isConnected()) { |
| 97 | 97 | $this->connection->close(); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * Test if there is an open connection to the irc server. |
| 104 | 104 | */ |
| 105 | - public function isConnected(): bool |
|
| 105 | + public function isConnected (): bool |
|
| 106 | 106 | { |
| 107 | 107 | return $this->connection && $this->connected; |
| 108 | 108 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param callable $function The function to be called. |
| 115 | 115 | */ |
| 116 | - public function onData(callable $function): void |
|
| 116 | + public function onData (callable $function): void |
|
| 117 | 117 | { |
| 118 | 118 | $this->eventHandlerCollection->addHandler('data', $function); |
| 119 | 119 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @throws Exception if no open connection is available. |
| 127 | 127 | */ |
| 128 | - public function write(string $command): void |
|
| 128 | + public function write (string $command): void |
|
| 129 | 129 | { |
| 130 | 130 | if (!$this->isConnected()) { |
| 131 | 131 | throw new Exception('No open connection was found to write commands to.'); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param IrcMessage $message The message received from the server. |
| 150 | 150 | */ |
| 151 | - private function handleMessage(IrcMessage $message): void |
|
| 151 | + private function handleMessage (IrcMessage $message): void |
|
| 152 | 152 | { |
| 153 | 153 | $this->eventHandlerCollection->invoke(new Event('data', [$message])); |
| 154 | 154 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** @var string */ |
| 27 | 27 | protected $source; |
| 28 | 28 | |
| 29 | - public function __construct(string $command) |
|
| 29 | + public function __construct (string $command) |
|
| 30 | 30 | { |
| 31 | 31 | $this->handled = false; |
| 32 | 32 | $this->parse($command); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param IrcClient $client A reference to the irc client object |
| 40 | 40 | * @param bool $force Force handling this message even if already handled. |
| 41 | 41 | */ |
| 42 | - public function handle(IrcClient $client, bool $force = false): void |
|
| 42 | + public function handle (IrcClient $client, bool $force = false): void |
|
| 43 | 43 | { |
| 44 | 44 | if ($this->handled && !$force) { |
| 45 | 45 | return; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return Event[] |
| 53 | 53 | */ |
| 54 | - public function getEvents() |
|
| 54 | + public function getEvents () |
|
| 55 | 55 | { |
| 56 | 56 | return []; |
| 57 | 57 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param IrcChannel[] $channels The list of irc channels in the IrcClient. |
| 64 | 64 | */ |
| 65 | - public function injectChannel(array $channels): void |
|
| 65 | + public function injectChannel (array $channels): void |
|
| 66 | 66 | { |
| 67 | 67 | // |
| 68 | 68 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param string $command |
| 74 | 74 | */ |
| 75 | - private function parse(string $command): void |
|
| 75 | + private function parse (string $command): void |
|
| 76 | 76 | { |
| 77 | 77 | $command = trim($command); |
| 78 | 78 | $this->rawMessage = $command; |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | |
| 7 | 7 | class MOTDMessage extends IrcMessage |
| 8 | 8 | { |
| 9 | - public function __construct(string $message) |
|
| 9 | + public function __construct (string $message) |
|
| 10 | 10 | { |
| 11 | 11 | parent::__construct($message); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function getEvents(): array |
|
| 14 | + public function getEvents (): array |
|
| 15 | 15 | { |
| 16 | 16 | return [ |
| 17 | 17 | new Event('motd', [$this->payload]), |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class PingMessage extends IrcMessage |
| 9 | 9 | { |
| 10 | - public function __construct(string $message) |
|
| 10 | + public function __construct (string $message) |
|
| 11 | 11 | { |
| 12 | 12 | parent::__construct($message); |
| 13 | 13 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Reply the ping message with a pong response. |
| 17 | 17 | */ |
| 18 | - public function handle(IrcClient $client, bool $force = false): void |
|
| 18 | + public function handle (IrcClient $client, bool $force = false): void |
|
| 19 | 19 | { |
| 20 | 20 | if ($this->handled && !$force) { |
| 21 | 21 | return; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $client->send("PONG :$this->payload"); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getEvents(): array |
|
| 27 | + public function getEvents (): array |
|
| 28 | 28 | { |
| 29 | 29 | return [ |
| 30 | 30 | new Event('ping'), |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** @var string */ |
| 17 | 17 | public $user; |
| 18 | 18 | |
| 19 | - public function __construct(string $message) |
|
| 19 | + public function __construct (string $message) |
|
| 20 | 20 | { |
| 21 | 21 | parent::__construct($message); |
| 22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * Change the topic for the referenced channel. |
| 29 | 29 | */ |
| 30 | - public function handle(IrcClient $client, bool $force = false): void |
|
| 30 | + public function handle (IrcClient $client, bool $force = false): void |
|
| 31 | 31 | { |
| 32 | 32 | if ($this->handled && !$force) { |
| 33 | 33 | return; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $client->getChannel($this->channel)->setTopic($this->topic); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function getEvents(): array |
|
| 39 | + public function getEvents (): array |
|
| 40 | 40 | { |
| 41 | 41 | return [ |
| 42 | 42 | new Event('topic', [$this->channel, $this->topic]), |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var string */ |
| 20 | 20 | public $user; |
| 21 | 21 | |
| 22 | - public function __construct(string $message) |
|
| 22 | + public function __construct (string $message) |
|
| 23 | 23 | { |
| 24 | 24 | parent::__construct($message); |
| 25 | 25 | $this->user = strstr($this->source, '!', true); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $this->message = $this->payload; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function getEvents(): array |
|
| 30 | + public function getEvents (): array |
|
| 31 | 31 | { |
| 32 | 32 | $events = []; |
| 33 | 33 | if ($this->target[0] === '#') { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return $events; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function injectChannel(array $channels): void |
|
| 47 | + public function injectChannel (array $channels): void |
|
| 48 | 48 | { |
| 49 | 49 | if (array_key_exists($this->target, $channels)) { |
| 50 | 50 | $this->channel = $channels[$this->target]; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class WelcomeMessage extends IrcMessage |
| 9 | 9 | { |
| 10 | - public function __construct(string $message) |
|
| 10 | + public function __construct (string $message) |
|
| 11 | 11 | { |
| 12 | 12 | parent::__construct($message); |
| 13 | 13 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * On welcome message, join the selected channels. |
| 17 | 17 | */ |
| 18 | - public function handle(IrcClient $client, bool $force = false): void |
|
| 18 | + public function handle (IrcClient $client, bool $force = false): void |
|
| 19 | 19 | { |
| 20 | 20 | if ($this->handled && !$force) { |
| 21 | 21 | return; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function getEvents(): array |
|
| 29 | + public function getEvents (): array |
|
| 30 | 30 | { |
| 31 | 31 | return [ |
| 32 | 32 | new Event('registered'), |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** @var string[] */ |
| 14 | 14 | public $names; |
| 15 | 15 | |
| 16 | - public function __construct(string $message) |
|
| 16 | + public function __construct (string $message) |
|
| 17 | 17 | { |
| 18 | 18 | parent::__construct($message); |
| 19 | 19 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $this->names = explode(' ', $this->payload); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function handle(IrcClient $client, bool $force = false): void |
|
| 24 | + public function handle (IrcClient $client, bool $force = false): void |
|
| 25 | 25 | { |
| 26 | 26 | if ($this->handled && !$force) { |
| 27 | 27 | return; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function getEvents(): array |
|
| 35 | + public function getEvents (): array |
|
| 36 | 36 | { |
| 37 | 37 | return [ |
| 38 | 38 | new Event('names', [$this->channel, $this->names]), |