|
4 | 4 |
|
5 | 5 | final class PNMessageType
|
6 | 6 | {
|
7 |
| - private $internal = null; |
8 |
| - private $custom = null; |
9 |
| - |
10 |
| - public function __construct($custom) |
| 7 | + private $pnMessageType = null; |
| 8 | + private $messageType = null; |
| 9 | + private $typeMapping = [ |
| 10 | + '0' => 'pn_message', |
| 11 | + '1' => 'pn_signal', |
| 12 | + '2' => 'pn_object', |
| 13 | + '3' => 'pn_message_action', |
| 14 | + '4' => 'pn_file', |
| 15 | + ]; |
| 16 | + |
| 17 | + public function __construct($messageType) |
11 | 18 | {
|
12 |
| - $this->custom = $custom; |
| 19 | + $this->messageType = $messageType; |
13 | 20 | }
|
14 | 21 |
|
15 |
| - public static function createWithInternal($custom, $internal) |
| 22 | + public static function createWithPnMessageType($messageType, $pnMessageType) |
16 | 23 | {
|
17 |
| - $messageType = new self($custom); |
18 |
| - $messageType->setInternal($internal); |
| 24 | + $messageType = new self($messageType); |
| 25 | + $messageType->setPnMessageType($pnMessageType); |
19 | 26 | return $messageType;
|
20 | 27 | }
|
21 | 28 |
|
22 |
| - private function setInternal($internal) |
| 29 | + private function setPnMessageType($pnMessageType) |
23 | 30 | {
|
24 |
| - $this->internal = $internal; |
| 31 | + $this->pnMessageType = $pnMessageType; |
25 | 32 | return $this;
|
26 | 33 | }
|
27 | 34 |
|
28 |
| - public function getInternal() |
| 35 | + public function getPnMessageType() |
29 | 36 | {
|
30 |
| - return $this->internal; |
| 37 | + return $this->typeMapping[$this->pnMessageType ? $this->pnMessageType : '0']; |
31 | 38 | }
|
32 | 39 |
|
33 | 40 | public function __toString()
|
34 | 41 | {
|
35 |
| - return $this->custom; |
| 42 | + return $this->messageType ? $this->messageType : $this->getPnMessageType(); |
36 | 43 | }
|
37 | 44 |
|
38 |
| - public function getCustom() |
| 45 | + public function getMessageType() |
39 | 46 | {
|
40 |
| - return $this->custom; |
| 47 | + return $this->messageType; |
41 | 48 | }
|
42 | 49 | }
|
0 commit comments