ts3phpframework
Loading...
Searching...
No Matches
Event.php
Go to the documentation of this file.
1<?php
2
4
5use ArrayAccess;
13
20class Event implements ArrayAccess
21{
28
34 protected array $data;
35
42
51 public function __construct(StringHelper $evt, Host $con = null)
52 {
53 if (!$evt->startsWith(TeamSpeak3::EVENT)) {
54 throw new AdapterException("invalid notification event format");
55 }
56
58
59 if (empty($data)) {
60 throw new AdapterException("invalid notification event data");
61 }
62
64 $repl = new Reply([$data, $fake], $type);
65
66 $this->type = $type->substr(strlen(TeamSpeak3::EVENT));
67 $this->data = $repl->toList();
68 $this->mesg = $data;
69
70 Signal::getInstance()->emit("notifyEvent", $this, $con);
71 Signal::getInstance()->emit("notify" . ucfirst($this->type), $this, $con);
72 }
73
79 public function getType(): StringHelper
80 {
81 return $this->type;
82 }
83
89 public function getData(): array
90 {
91 return $this->data;
92 }
93
99 public function getMessage(): StringHelper
100 {
101 return $this->mesg;
102 }
103
107 public function offsetExists($offset): bool
108 {
109 return array_key_exists($offset, $this->data);
110 }
111
116 public function offsetGet($offset): mixed
117 {
118 if (!$this->offsetExists($offset)) {
119 throw new ServerQueryException("invalid parameter", 0x602);
120 }
121
122 return $this->data[$offset];
123 }
124
129 public function offsetSet($offset, $value): void
130 {
131 throw new NodeException("event '" . $this->getType() . "' is read only");
132 }
133
137 public function offsetUnset($offset): void
138 {
139 unset($this->data[$offset]);
140 }
141
146 public function __get($offset)
147 {
148 return $this->offsetGet($offset);
149 }
150
155 public function __set($offset, $value)
156 {
157 $this->offsetSet($offset, $value);
158 }
159}
Provides methods to analyze and format a ServerQuery event.
Definition Event.php:21
__construct(StringHelper $evt, Host $con=null)
Definition Event.php:51
Provides methods to analyze and format a ServerQuery reply.
Definition Reply.php:19
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\Adapter objects.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Node\Node objects.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Class describing a TeamSpeak 3 server instance and all it's parameters.
Definition Host.php:23
Factory class all for TeamSpeak 3 PHP Framework objects.
const SEPARATOR_CELL
protocol cell separator
const SEPARATOR_PAIR
protocol pair separator