You are here

function ISN_classifier in ISBN Field 6

2 calls to ISN_classifier()
ISBN_classifier in ./isbn.inc
ISSN_classifier in ./isbn.inc

File

./isbn.inc, line 402

Code

function ISN_classifier($clean, $length) {
  $bad_chars = bad_ISN_char_count($clean);
  if (strlen($clean) < $length - 1) {
    return $bad_chars == 0 ? "short" : "short/invalid";
  }
  elseif (strlen($clean) == $length - 1) {
    return $bad_chars == 0 ? "single_error" : "short/invalid";
  }
  elseif (strlen($clean) == $length) {
    if ($bad_chars == 0) {
      if (mod11_checksum($clean, $length) == 0) {
        return "checksumOK";
      }
      else {
        return "single_error";
      }
    }
    else {
      return $bad_chars == 1 ? "single_error" : "invalid";
    }
  }
  elseif (strlen($clean) == $length + 1) {
    if ($bad_chars == 0) {
      return "single_error";
    }
    elseif ($bad_chars == 1 && mod11_checksum($clean, $length) == 0) {
      return "single_error";
    }
    else {
      return "long/invalid";
    }
  }
  else {
    return $bad_chars == 0 ? "long" : "long/invalid";
  }
}