public function calcMod10V1(string $number, string $separator = "", int $minimumLength = 6): string
    {
        $revstr = strrev((string) intval($number));
        $revstrLen = strlen($revstr);
        $total = 0;
        for ($i = 0; $i < $revstrLen; $i++) {
            if ($i % 2 == 0) {
                $multiplier = 2;
            } else {
                $multiplier = 1;
            }

            $subtotal = intval($revstr[$i]) * $multiplier;
            if ($subtotal >= 10) {
                $temp = (string) $subtotal;
                $subtotal = intval($temp[0]) + intval($temp[1]);
            }
            $total += $subtotal;
        }

        $checkDigit = (10 - ($total % 10)) % 10;
        $crn = str_pad(ltrim($number, "0"), $minimumLength - 1, "0", STR_PAD_LEFT) . $separator . $checkDigit;

        return $crn;
    }
public function calcMod10V1(string $number, string $separator = "", int $minimumLength = 6): string
    {
        $revstr = strrev((string) intval($number));
        $revstrLen = strlen($revstr);
        $total = 0;
        for ($i = 0; $i < $revstrLen; $i++) {
            if ($i % 2 == 0) {
                $multiplier = 2;
            } else {
                $multiplier = 1;
            }

            $subtotal = intval($revstr[$i]) * $multiplier;
            if ($subtotal >= 10) {
                $temp = (string) $subtotal;
                $subtotal = intval($temp[0]) + intval($temp[1]);
            }
            $total += $subtotal;
        }

        $checkDigit = (10 - ($total % 10)) % 10;
        $crn = str_pad(ltrim($number, "0"), $minimumLength - 1, "0", STR_PAD_LEFT) . $separator . $checkDigit;

        return $crn;
    }
public function calcMod10V1 ( string $ number , string $ separator = "" , int $ minimumLength = 6 ) : string { $ revstr = strrev ( ( string ) intval ( $ number ) ) ; $ revstrLen = strlen ( $ revstr ) ; $ total = 0 ; for ( $ i = 0 ; $ i < $ revstrLen ; $ i ++ ) { if ( $ i % 2 == 0 ) { $ multiplier = 2 ; } else { $ multiplier = 1 ; } $ subtotal = intval ( $ revstr [ $ i ] ) * $ multiplier ; if ( $ subtotal >= 10 ) { $ temp = ( string ) $ subtotal ; $ subtotal = intval ( $ temp [ 0 ] ) + intval ( $ temp [ 1 ] ) ; } $ total += $ subtotal ; } $ checkDigit = ( 10 - ( $ total % 10 ) ) % 10 ; $ crn = str_pad ( ltrim ( $ number , "0" ) , $ minimumLength - 1 , "0" , STR_PAD_LEFT ) . $ separator . $ checkDigit ; return $ crn ; }
Calculate Modulus 10 Version 1.

@param string $number
@param string $separator
@param int $minimumLength
@return string
Calculate Modulus 10 Version 1 .