<?php

class Tracking_USPS_gsbarcode {

    /**
     *
     * @global type $SETTINGS
     * @param string $code
     * @return \TrackingInfo
     * @throws TrackingException
     */
    public static function track(string $code): TrackingInfo {
        if (strpos($code, "\x1D") === 0) {
            $code = substr($code, 1);
        }
        $codeparts = explode("\x1D", $code);
        if (count($codeparts) == 1) {
            $realcode = $codeparts[0];
        } else {
            // Has routing portion, let's skip that
            $realcode = $codeparts[1];
        }

        return Tracking::track($realcode, "usps");
    }

}
