summaryrefslogtreecommitdiffstats
path: root/vendor/textalk/websocket/lib/Message/Message.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/textalk/websocket/lib/Message/Message.php')
-rw-r--r--vendor/textalk/websocket/lib/Message/Message.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/textalk/websocket/lib/Message/Message.php b/vendor/textalk/websocket/lib/Message/Message.php
new file mode 100644
index 0000000..998caa1
--- /dev/null
+++ b/vendor/textalk/websocket/lib/Message/Message.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace WebSocket\Message;
+
+use DateTime;
+
+abstract class Message
+{
+ protected $opcode;
+ protected $payload;
+ protected $timestamp;
+
+ public function __construct(string $payload = '')
+ {
+ $this->payload = $payload;
+ $this->timestamp = new DateTime();
+ }
+
+ public function getOpcode(): string
+ {
+ return $this->opcode;
+ }
+
+ public function getLength(): int
+ {
+ return strlen($this->payload);
+ }
+
+ public function getTimestamp(): DateTime
+ {
+ return $this->timestamp;
+ }
+
+ public function getContent(): string
+ {
+ return $this->payload;
+ }
+
+ public function setContent(string $payload = ''): void
+ {
+ $this->payload = $payload;
+ }
+
+ public function hasContent(): bool
+ {
+ return $this->payload != '';
+ }
+
+ public function __toString(): string
+ {
+ return get_class($this);
+ }
+}