Faker\Test\Provider\ro_RO\PersonTest::isValidCnp PHP Méthode

isValidCnp() protected méthode

protected isValidCnp ( $cnp )
    protected function isValidCnp($cnp)
    {
        if (preg_match(static::TEST_CNP_REGEX, $cnp) !== false) {
            $checkNumber = 279146358279;
            $checksum = 0;
            foreach (range(0, 11) as $digit) {
                $checksum += (int) substr($cnp, $digit, 1) * (int) substr($checkNumber, $digit, 1);
            }
            $checksum = $checksum % 11;
            $checksum = $checksum == 10 ? 1 : $checksum;
            if ($checksum == substr($cnp, -1)) {
                return true;
            }
        }
        return false;
    }