Skip to content

Commit

Permalink
Deprecate other values than string for CreditCard
Browse files Browse the repository at this point in the history
Test for card number `6304100000000008` fails on windows because a number this long can't be stored as an integer.
Instead it becomes a float and when converted into string it is 6.3041E+15 instead of 6304100000000008.

CreditCard::validate should only allow string arguments.

This is done in a BC way and should be updated for next major.
  • Loading branch information
soullivaneuh committed May 14, 2016
1 parent 4bd68b9 commit 1479765
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/IsoCodes/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class CreditCard implements IsoCodeInterface
*/
public static function validate($creditCard)
{
if (!is_string($creditCard)) {
@trigger_error(
'Passing other values than a string on '.__METHOD__.' is deprecated since version 2.2.'
.' It will be considered as invalid on version 3.0.',
E_USER_DEPRECATED
);
}

// Add !is_string($creditCard) to the condition on 3.0.
if (trim($creditCard) === '') {
return false;
}
Expand Down

0 comments on commit 1479765

Please sign in to comment.