|
24 | 24 |
|
25 | 25 | class UserEvent extends AbstractModel |
26 | 26 | { |
27 | | - public string $ID = ''; |
28 | | - public string $Name = ''; |
29 | | - public string $Payload = ''; |
30 | | - public string $NodeFilter = ''; |
31 | | - public string $ServiceFilter = ''; |
32 | | - public string $TagFilter = ''; |
33 | | - public int $Version = 0; |
34 | | - public int $LTime = 0; |
35 | | - |
36 | | - /** |
37 | | - * UserEvent constructor. |
38 | | - * |
39 | | - * @param bool $_decodeValue |
40 | | - */ |
41 | | - public function __construct(array $data = [], bool $_decodeValue = false) |
42 | | - { |
43 | | - parent::__construct($data); |
44 | | - if ($_decodeValue) { |
45 | | - $dec = base64_decode($this->Payload, true); |
46 | | - if (false === $dec) { |
47 | | - throw new \InvalidArgumentException(sprintf('Could not base64 decode payload "%s"', $this->Payload)); |
48 | | - } |
49 | | - $this->Payload = $dec; |
50 | | - } |
| 27 | + public string $ID; |
| 28 | + public string $Name; |
| 29 | + public string $Payload; |
| 30 | + public string $NodeFilter; |
| 31 | + public string $ServiceFilter; |
| 32 | + public string $TagFilter; |
| 33 | + public int $Version; |
| 34 | + public int $LTime; |
| 35 | + |
| 36 | + public function __construct( |
| 37 | + string $ID = '', |
| 38 | + string $Name = '', |
| 39 | + string $Payload = '', |
| 40 | + string $NodeFilter = '', |
| 41 | + string $ServiceFilter = '', |
| 42 | + string $TagFilter = '', |
| 43 | + int $Version = 0, |
| 44 | + int $LTime = 0 |
| 45 | + ) { |
| 46 | + $this->ID = $ID; |
| 47 | + $this->Name = $Name; |
| 48 | + $this->Payload = $Payload; |
| 49 | + $this->NodeFilter = $NodeFilter; |
| 50 | + $this->ServiceFilter = $ServiceFilter; |
| 51 | + $this->TagFilter = $TagFilter; |
| 52 | + $this->Version = $Version; |
| 53 | + $this->LTime = $LTime; |
51 | 54 | } |
52 | 55 |
|
53 | 56 | public function getID(): string |
@@ -89,4 +92,27 @@ public function getLTime(): int |
89 | 92 | { |
90 | 93 | return $this->LTime; |
91 | 94 | } |
| 95 | + |
| 96 | + public static function jsonUnserialize(\stdclass $decoded): self |
| 97 | + { |
| 98 | + $n = new self(); |
| 99 | + foreach ($decoded as $k => $v) { |
| 100 | + $n->{$k} = $v; |
| 101 | + } |
| 102 | + return $n; |
| 103 | + } |
| 104 | + |
| 105 | + public function jsonSerialize(): \stdClass |
| 106 | + { |
| 107 | + $out = $this->_startJsonSerialize(); |
| 108 | + $out->ID = $this->ID; |
| 109 | + $out->Name = $this->Name; |
| 110 | + $out->Payload = $this->Payload; |
| 111 | + $out->NodeFilter = $this->NodeFilter; |
| 112 | + $out->ServiceFilter = $this->ServiceFilter; |
| 113 | + $out->TagFilter = $this->TagFilter; |
| 114 | + $out->Version = $this->Version; |
| 115 | + $out->LTime = $this->LTime; |
| 116 | + return $out; |
| 117 | + } |
92 | 118 | } |
0 commit comments