You are here

function _brazilianids_is_cpf_cnpj in Brazilian IDs 6

Return 'CPF' or 'CNPJ' depend of the type of param

Parameters

&$cpfcnpj: Number, to determine type

Return value

String, the string 'CPF' if type of $cpfcnpj is CPF or 'CNPJ' if is a cpnj number or false if not valid CPF/CNPJ

2 calls to _brazilianids_is_cpf_cnpj()
brazilianids_field in ./brazilianids_cck.inc
Implementation of hook_field().
brazilianids_user in ./brazilianids.module
Implementation of hook_user().

File

./brazilianids.check.inc, line 69
brazilianids.check.inc

Code

function _brazilianids_is_cpf_cnpj($cpfcnpj) {
  $cpfcnpj = _brazilianids_clean_cpfcnpj($cpfcnpj);
  $return = $cpfcnpj;
  if (drupal_strlen($cpfcnpj) == 11) {
    $return = _brazilianids_validate_cpf($cpfcnpj);
  }
  elseif (drupal_strlen($cpfcnpj) == 14) {
    $return = _brazilianids_validate_cnpj($cpfcnpj);
  }
  else {
    $return = FALSE;
  }
  if (!$return) {
    return NULL;
  }
  if (drupal_strlen($return) == 11) {
    return 'CPF';
  }
  elseif (drupal_strlen($return) == 14) {
    return 'CNPJ';
  }
  else {
    return NULL;
  }
}