id = $id; $this->title = $title; $this->begin = $begin; $this->end = $end; $this->location = $location; $this->description = $description; $this->tags = $tags; } } /** */ function event_to_raw( struct_event $event ) { return [ 'id' => $event->id, 'title' => $event->title, 'begin' => $event->begin, 'end' => $event->end, 'location' => $event->location, 'description' => $event->description, 'tags' => $event->tags, ]; } /** */ function event_from_raw( $event_raw ) : struct_event { return (new struct_event( $event_raw['id'], $event_raw['title'], $event_raw['begin'], $event_raw['end'], $event_raw['location'], $event_raw['description'], $event_raw['tags'], )); } /** */ class struct_calendar { public array $events; public function __construct( array $events ) { $this->events = $events; } } /** */ function calendar_to_raw( struct_calendar $calendar ) { return [ 'events' => \array_map( fn($event) => event_to_raw($event), $calendar->events ), ]; } /** */ function calendar_from_raw( $calendar_raw ) : struct_calendar { return (new struct_calendar( \array_map( fn($event_raw) => event_from_raw($event_raw), $calendar_raw['events'] ) )); } ?>