Faker\Provider\ro_RO\Person::getChecksumDigit PHP Method

getChecksumDigit() protected method

Calculates a checksum for the Personal Numerical Code (CNP).
protected getChecksumDigit ( string $value ) : integer
$value string 12 digit CNP
return integer checksum digit
    protected function getChecksumDigit($value)
    {
        $checkNumber = 279146358279;
        $checksum = 0;
        foreach (range(0, 11) as $digit) {
            $checksum += (int) substr($value, $digit, 1) * (int) substr($checkNumber, $digit, 1);
        }
        $checksum = $checksum % 11;
        return $checksum == 10 ? 1 : $checksum;
    }