diff options
Diffstat (limited to 'src/Message.php')
-rw-r--r-- | src/Message.php | 36 |
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 |