USPS Restrictions Parser

USPS returns a large block of text stating restrictions, we provide you with a convenient way to parse this:

<?php
$helper = new \RocketShipIt\Helper\Restrictions;
$helper->load($restrictionTextFromUSPS);
$resp = $helper->parseRestrictions();

Example output would like this:

array(
    [A1] => Mail addressed to “Any Servicemember,” or similar wording such as “Any Soldier,” “Sailor,” “Airman,” or “Marine”; “Military Mail”; etc., is prohibited. Mail must be addressed to an individual or job title such as “Commander,” “Commanding Officer,” etc.
    [A2] => APO/FPO/DPO addresses shall not include a city and/or country name.
    [B] => Regardless of mail class, a customs declaration (PS Form 2976 or, if the customer prefers, PS Form 2976-A) is required for all items weighing 16 ounces or more or any item (regardless of weight) containing potentially dutiable mail contents (e.g., merchandise or goods) addressed to or from an APO, FPO, or DPO ZIP Code. No customs form is required for items weighing less than 16 ounces when the contents are not potentially dutiable (e.g., documents). The surface area of the address side of the mailpiece must be large enough to contain the applicable customs declaration. The following exceptions apply:
        n Known mailers are exempt from providing customs documentation on non-dutiable letters or printed matter. (A known mailer is a business mailer who enters volume mailings through a business mail entry unit (BMEU) or other bulk mail acceptance location, pays postage through an advance deposit account, uses a permit imprint for postage payment, and submits a completed postage statement at the time of entry that certifies that the mailpieces contain no dangerous materials that are prohibited by postal regulations.)
        n All federal, state, and local government agencies whose mailings are regarded as “Official Mail” are exempt from providing customs documentation on any item addressed to an APO, FPO, or DPO except for those APOs/FPOs/DPOs to which restriction "B2" applies.
       n Prepaid mail from military contractors is exempt, providing the mailpiece is endorsed “Contents for Official Use — Exempt from Customs Requirements.”
    [C] => Cigarettes and other tobacco products are prohibited.
    [F] => Firearms of any type are prohibited in all classes of mail. See definitions of firearms in DMM 601.12.1.1. This restriction does not apply to firearms mailed to or by official U.S. government agencies. The restriction for mail to this APO/FPO/DPO ZIP Code does not apply to firearms mailed from this APO/FPO/DPO ZIP Code, provided ATF and USPS regulations are met. Antique firearms are a separate category defined in DMM 601.12.1.1h and ATF regulations; they do not require an ATF form.
    [R] => All alcoholic beverages, including those mailable under DMM 601.12.7, are prohibited.
    [U] => Parcels must weigh less than 16 ounces when addressed to Box R. This restriction does not apply to mail endorsed “Free Matter for the Blind or Handicapped.”
)

See also: USPS Restrictions Legend