aboutsummaryrefslogtreecommitdiff
path: root/src/Message.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-02-26 03:40:02 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-26 03:40:02 +0300
commitada8a13ce8a3410f4260601d213404bff5fa1cc7 (patch)
treea3ae5a714cf1fc5ebe5ce76175746b4b0c8a7abe /src/Message.php
initial
Diffstat (limited to 'src/Message.php')
-rw-r--r--src/Message.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Message.php b/src/Message.php
new file mode 100644
index 0000000..647afad
--- /dev/null
+++ b/src/Message.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace jobd;
+
+
+abstract class Message {
+
+ const REQUEST = 0;
+ const RESPONSE = 1;
+
+ protected $type;
+
+ /**
+ * Message constructor.
+ * @param int $type
+ */
+ public function __construct(int $type) {
+ $this->type = $type;
+ }
+
+ /**
+ * @return array
+ */
+ abstract protected function getContent(): array;
+
+ /**
+ * @return string
+ */
+ public function serialize(): string {
+ return json_encode([
+ $this->type,
+ $this->getContent()
+ ]);
+ }
+
+} \ No newline at end of file