Skip to content

Commit

Permalink
phalcon#16477 - Add digits check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Dec 23, 2023
1 parent a36c7d8 commit f6319f1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions phalcon/Filter/Validation/Validator/CreditCard.zep
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ class CreditCard extends AbstractValidator
*/
private function verifyByLuhnAlgorithm(string number) -> bool
{
var digit, position, hash = "", result;
array digits;
var digit, digits, position, hash = "", result;

let digits = (array) str_split(number);
if (ctype_digit(number) === false) {
return false;
}

let digits = array_reverse(str_split(number));

for position, digit in digits->reversed() {
for position, digit in digits {
let hash .= (position % 2 ? digit * 2 : digit);
}

Expand Down

0 comments on commit f6319f1

Please sign in to comment.