/**
* Detects the credit card type based on the number.
*
* @param string $number
* The credit card number.
*
* @return \Drupal\commerce_payment\CreditCardType|null
* The credit card type, or NULL if unknown.
*/
public static function detectType($number) {
if (!is_numeric($number)) {
return FALSE;
}
$types = self::getTypes();
foreach ($types as $type) {
foreach ($type->getNumberPrefixes() as $prefix) {
if (self::matchPrefix($number, $prefix)) {
return $type;
}
}
}
return FALSE;
}
We document NULL, but return FALSE.
PHP saves us, but this is still unclean. The general D8 pattern is NULL, not FALSE, so the docs are correct, not the code.
Comments
Comment #3
bojanz commentedFixed.