src/RijksregisternummerHelper.php
/**
   * Returns true if a string is a valid identification number of the National Register, false otherwise.
   *
   * @param string $rijksregisternummer The clean and valid identification number of the National Register.
   *
   * @return bool
   *
   * @since 1.0.0
   * @api
   */
Returns true if a string is a valid identification number of the National Register, false otherwise.
@param string $rijksregisternummer The clean and valid identification number of the National Register.

@return bool


Returns true if a string is a valid identification number of the National Register false otherwise . @param string $rijksregisternummer The clean and valid identification number of the National Register . @return bool
public static function isValid(string $rijksregisternummer): bool
  {
    if (preg_match('/^\d+$/', $rijksregisternummer)!=1)
    {
      return false;
    }
    if (strlen($rijksregisternummer)<>11)
    {
      return false;
    }
    $part1 = (int)substr($rijksregisternummer, 0, 9);
    $part2 = (int)substr($rijksregisternummer, 9, 2);
    $check = 97 - ($part1 % 97);
    if ($check==$part2)
    {
      $born1900 = true;
    }
    else
    {
      $check = 97 - ((2000000000 + $part1) % 97);
      if ($check!=$part2)
      {
        return false;
      }
      $born1900 = false;
    }
    $year  = (int)((($born1900) ? '19' : '20').substr($rijksregisternummer, 0, 2));
    $month = (int)substr($rijksregisternummer, 2, 2);
    $day   = (int)substr($rijksregisternummer, 4, 2);
    if ($month==0)
    {
      return ((0<=$day && $day<=31) && (1900<=$year && $year<=idate('Y')));
    }
    $month = self::readjustMonth($month);
    if (!checkdate($month, $day, $year))
    {
      return false;
    }
    $counter = (int)substr($rijksregisternummer, 6, 3);
    if (!(1<=$counter && $counter<=998))
    {
      return false;
    }
    return true;
  }
public static function isValid ( string $ rijksregisternummer ) : bool { if ( preg_match ( '/^\d+$/' , $ rijksregisternummer ) != 1 ) { return false ; } if ( strlen ( $ rijksregisternummer ) <> 11 ) { return false ; } $ part1 = ( int ) substr ( $ rijksregisternummer , 0 , 9 ) ; $ part2 = ( int ) substr ( $ rijksregisternummer , 9 , 2 ) ; $ check = 97 - ( $ part1 % 97 ) ; if ( $ check == $ part2 ) { $ born1900 = true ; } else { $ check = 97 - ( ( 2000000000 + $ part1 ) % 97 ) ; if ( $ check != $ part2 ) { return false ; } $ born1900 = false ; } $ year = ( int ) ( ( ( $ born1900 ) ? '19' : '20' ) . substr ( $ rijksregisternummer , 0 , 2 ) ) ; $ month = ( int ) substr ( $ rijksregisternummer , 2 , 2 ) ; $ day = ( int ) substr ( $ rijksregisternummer , 4 , 2 ) ; if ( $ month == 0 ) { return ( ( 0 <= $ day && $ day <= 31 ) && ( 1900 <= $ year && $ year <= idate ( 'Y' ) ) ) ; } $ month = self :: readjustMonth ( $ month ) ; if ( ! checkdate ( $ month , $ day , $ year ) ) { return false ; } $ counter = ( int ) substr ( $ rijksregisternummer , 6 , 3 ) ; if ( ! ( 1 <= $ counter && $ counter <= 998 ) ) { return false ; } return true ; }
Returns true if a string is a valid identification number of the National Register, false otherwise.
Returns true if a string is a valid identification number of the National Register false otherwise .
// Test the rijksregisternummer has only digits. // Test length is 11. // Test check part. // Test birthday is valid. // Test counter. The counter must between 1 and 998.