Skip to content

Commit

Permalink
Fix PHP 7.4 deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMY3 committed Feb 3, 2020
1 parent 5b765dd commit 3af8a46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,13 @@ protected static function luhnCheck($number)
{
$checksum = 0;
for ($i = (2 - (strlen($number) % 2)); $i <= strlen($number); $i += 2) {
$checksum += (int)($number{$i - 1});
$checksum += (int) substr($number, $i - 1, 1);
}

// Analyze odd digits in even length strings or even digits in odd length strings.
for ($i = (strlen($number) % 2) + 1; $i < strlen($number); $i += 2) {
$digit = (int)($number{$i - 1}) * 2;
$digit = (int) substr($number, $i - 1, 1);
$digit *= 2;
if ($digit < 10) {
$checksum += $digit;
} else {
Expand Down

0 comments on commit 3af8a46

Please sign in to comment.