public static function serializeRide($ride) { $result = []; if (!empty($ride)) { $result = ['id' => $ride->id, 'route' => DbUtil::serializeRoute($ride->headRoute), 'joinedUsers' => DbUtil::serializeUsers($ride->joinedUsers), 'owner_id' => $ride->initiator]; if (isset($ride->number_of_requests)) { $result['number_of_requests'] = $ride->number_of_requests; } } return $result; }