getCode())); } catch (Exception $ex) { throw new TrackingException("There was a server problem. This code cannot be tracked right now."); } if (empty($status->events) && empty($status->info->carrier)) { throw new TrackingException("Unknown tracking code (best guess: " . Carriers::getCarrierName($barcode->getCarrier()) . ")."); } $info = new TrackingInfo(); $info->setCode($barcode->getCode()); $info->setCarrier($status->info->carrier); if (!empty($status->events)) { $current_status = new TrackingEntry( TrackingStatus::stringToStatus($status->events[0]->eventtype), $status->events[0]->text, $status->events[0]->timestring ); $info->setCurrentStatus($current_status); } foreach ($status->events as $event) { $info->appendHistoryEntry(new TrackingEntry(TrackingStatus::stringToStatus($event->eventtype), $event->text, $event->timestring)); } return $info; } }