TCPDFBarcode::checksum_code39 PHP Method

checksum_code39() protected method

Calculate CODE 39 checksum (modulo 43).
protected checksum_code39 ( $code ) : char
$code (string) code to represent.
return char checksum.
    protected function checksum_code39($code)
    {
        $chars = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
        $sum = 0;
        $clen = strlen($code);
        for ($i = 0; $i < $clen; ++$i) {
            $k = array_keys($chars, $code[$i]);
            $sum += $k[0];
        }
        $j = $sum % 43;
        return $chars[$j];
    }