ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
JSONSerializer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 class JSONSerializer implements Serializer
27 {
28  public function __construct()
29  {
30  }
31 
32  public function serializePayload(array $payload_data): string
33  {
34  return json_encode($payload_data, JSON_THROW_ON_ERROR);
35  }
36 
37  public function unserializePayload(string $payload_string): array
38  {
39  return json_decode($payload_string, true, 512, JSON_THROW_ON_ERROR);
40  }
41 
42  public function serializeValidity(?int $valid_until_timestamp): string
43  {
44  return (string) ($valid_until_timestamp ?? '');
45  }
46 
47  public function unserializeValidity(string $valid_until_string): ?int
48  {
49  return $valid_until_string === '' ? null : (int) $valid_until_string;
50  }
51 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null