/** * Epand 8 * * Expand a 8-digit UPC-E code to UPC-A 12 digit code. * The first digit becomes the UPC-E Check Number and then the * first and last digits are stripped. The last digit is then * re-appended as the check digit; * * @param string $upc UPC-E Code to expand * @return Returns the expanded UPC code */ private static function expand8($upc) { // Get literal first and last digits $first = substr($upc, 0, 1); $last = substr($upc, 7, 1); // Strip UPC to middle 6 digits $upc = substr($upc, 1, 6); // Create UPC from 6 digit value $upc = UpcEExpander::createUpcA($upc, $last, $last); // Get new check digit and append $checkDigit = \ProductValidator\UpcValidator\UpcValidator::getCheckDigit($upc); $upc = substr($upc, 0, 11) . $checkDigit; return $upc; }