blob: 647afadad1fff90ea7fc09209a200acb724972ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()
]);
}
}
|