public static function validate($isbn, $type = null)
{
if ($type !== null && !in_array($type, [10, 13], true)) {
throw new \InvalidArgumentException('ISBN type option must be 10 or 13');
}
$isbn = str_replace(' ', '', $isbn);
$isbn = str_replace('-', '', $isbn);
// this is a dash
$isbn = str_replace('‐', '', $isbn);
// this is an authentic hyphen
if ($type === 10) {
return self::validateIsbn10($isbn);
}
if ($type === 13) {
return self::validateIsbn13($isbn);
}
return self::validateIsbn10($isbn) || self::validateIsbn13($isbn);
}