Skip to content

Commit

Permalink
Only accept string values for CreditCard
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed Apr 26, 2016
1 parent 7d558fd commit e9d1d5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/IsoCodes/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CreditCard implements IsoCodeInterface
*/
public static function validate($creditCard)
{
if (trim($creditCard) === '') {
if (!is_string($creditCard) || trim($creditCard) === '') {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion tests/IsoCodes/Tests/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function getValidCreditCards()
array('4903010000000009'), //Switch
array('4111111111111111'), //Visa
array('6304100000000008'), //Laser
array(6304100000000008), //Laser
);
}

Expand All @@ -44,6 +43,8 @@ public function getInvalidCreditCards()
return array(
array('CE1EL2LLFFF'),
array('E31DCLLFFF'),
// Valid card but not a string. See: https://github.com/ronanguilloux/IsoCodes/issues/75
array(6304100000000008),
array(''),
array(' ')
);
Expand Down

0 comments on commit e9d1d5a

Please sign in to comment.