jerodev /
php-irc-client
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Jerodev\PhpIrcClient\Messages; |
||
| 6 | |||
| 7 | use Jerodev\PhpIrcClient\Helpers\Event; |
||
| 8 | use Jerodev\PhpIrcClient\IrcChannel; |
||
| 9 | use Jerodev\PhpIrcClient\IrcClient; |
||
| 10 | |||
| 11 | class ModeMessage extends IrcMessage |
||
| 12 | { |
||
| 13 | public string $mode; |
||
| 14 | public ?string $target = null; |
||
| 15 | public string $user; |
||
| 16 | |||
| 17 | public function __construct(string $command) |
||
| 18 | { |
||
| 19 | parent::__construct($command); |
||
| 20 | if ('#' === $this->commandsuffix[0]) { |
||
| 21 | [$this->target, $this->mode] = explode(' ', $this->commandsuffix); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 22 | $this->user = $this->payload; |
||
| 23 | $this->channel = new IrcChannel($this->target); |
||
| 24 | } else { |
||
| 25 | $this->user = $this->commandsuffix; |
||
| 26 | $this->mode = $this->payload; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return array<int, Event> |
||
| 32 | */ |
||
| 33 | public function getEvents(): array |
||
| 34 | { |
||
| 35 | return [ |
||
| 36 | new Event('mode', [$this->channel, $this->user, $this->mode]), |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | } |
||
| 40 |