for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Jerodev\PhpIrcClient\Messages;
use Jerodev\PhpIrcClient\Helpers\EventArgs;
use Jerodev\PhpIrcClient\IrcClient;
class IrcMessage
{
/** @var string */
private $rawMessage;
protected $command;
protected $commandsuffix;
/** @var bool */
protected $handled;
protected $payload;
protected $source;
public function __construct(string $message)
$this->handled = false;
$this->rawMessage = $message;
if (preg_match('/^(?::(?<source>[^\s]+)\s*)?(?<command>[^\s]+)\s*(?<commandsuffix>[^:$]+)?\s*(?::(?<payload>.*?))?$/', $message, $matches)) {
$this->source = $matches['source'] ?? null;
$this->command = $matches['command'] ?? null;
$this->commandsuffix = trim($matches['commandsuffix'] ?? null);
$this->payload = $matches['payload'] ?? null;
}
/**
* This function is always called after the message is parsed.
* The handle will only be executed once unless forced.
*
* @param IrcClient $client A reference to the irc client object
* @param bool $force Force handling this message even if already handled.
*/
public function handle(IrcClient $client, bool $force = false): void
$client
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function handle(/** @scrutinizer ignore-unused */ IrcClient $client, bool $force = false): void
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if ($this->handled && !$force) {
return;
* Get the arguments needed for the event callback for this message.
* @return EventArgs[] An array of event args to emit.
public function getEventArgs(): array
return [];
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.