src/Biblys/Isbn/Isbn.php
private function calculateChecksum($format = 'EAN')
    {
        $sum = null;

        if ($format == 'ISBN-10') {
            $code = $this->getCountry().$this->getPublisher().$this->getPublication();
            $c = str_split($code);
            $sum = (11 - (($c[0] * 10) + ($c[1] * 9) + ($c[2] * 8) + ($c[3] * 7) + ($c[4] * 6) + ($c[5] * 5) + ($c[6] * 4) + ($c[7] * 3) + ($c[8] * 2)) % 11) % 11;
            if ($sum == 10) {
                $sum = 'X';
            }
        } else {
            $code = $this->getProduct().$this->getCountry().$this->getPublisher().$this->getPublication();
            $c = str_split($code);
            $sum = (($c[1] + $c[3] + $c[5] + $c[7] + $c[9] + $c[11]) * 3) + ($c[0] + $c[2] + $c[4] + $c[6] + $c[8] + $c[10]);
            $sum = (10 - ($sum % 10)) % 10;
        }

        $this->setChecksum($sum);
    }
private function calculateChecksum($format = 'EAN')
    {
        $sum = null;

        if ($format == 'ISBN-10') {
            $code = $this->getCountry().$this->getPublisher().$this->getPublication();
            $c = str_split($code);
            $sum = (11 - (($c[0] * 10) + ($c[1] * 9) + ($c[2] * 8) + ($c[3] * 7) + ($c[4] * 6) + ($c[5] * 5) + ($c[6] * 4) + ($c[7] * 3) + ($c[8] * 2)) % 11) % 11;
            if ($sum == 10) {
                $sum = 'X';
            }
        } else {
            $code = $this->getProduct().$this->getCountry().$this->getPublisher().$this->getPublication();
            $c = str_split($code);
            $sum = (($c[1] + $c[3] + $c[5] + $c[7] + $c[9] + $c[11]) * 3) + ($c[0] + $c[2] + $c[4] + $c[6] + $c[8] + $c[10]);
            $sum = (10 - ($sum % 10)) % 10;
        }

        $this->setChecksum($sum);
    }
private function calculateChecksum ( $ format = 'EAN' ) { $ sum = null ; if ( $ format == 'ISBN-10' ) { $ code = $ this -> getCountry ( ) . $ this -> getPublisher ( ) . $ this -> getPublication ( ) ; $ c = str_split ( $ code ) ; $ sum = ( 11 - ( ( $ c [ 0 ] * 10 ) + ( $ c [ 1 ] * 9 ) + ( $ c [ 2 ] * 8 ) + ( $ c [ 3 ] * 7 ) + ( $ c [ 4 ] * 6 ) + ( $ c [ 5 ] * 5 ) + ( $ c [ 6 ] * 4 ) + ( $ c [ 7 ] * 3 ) + ( $ c [ 8 ] * 2 ) ) % 11 ) % 11 ; if ( $ sum == 10 ) { $ sum = 'X' ; } } else { $ code = $ this -> getProduct ( ) . $ this -> getCountry ( ) . $ this -> getPublisher ( ) . $ this -> getPublication ( ) ; $ c = str_split ( $ code ) ; $ sum = ( ( $ c [ 1 ] + $ c [ 3 ] + $ c [ 5 ] + $ c [ 7 ] + $ c [ 9 ] + $ c [ 11 ] ) * 3 ) + ( $ c [ 0 ] + $ c [ 2 ] + $ c [ 4 ] + $ c [ 6 ] + $ c [ 8 ] + $ c [ 10 ] ) ; $ sum = ( 10 - ( $ sum % 10 ) ) % 10 ; } $ this -> setChecksum ( $ sum ) ; }
Calculate checksum character
Calculate checksum character