Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making it compatible with php >= 7.4 #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/CreditCard.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

/**
* Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm.
* Also validates the CVC and the expiration date.
*
* @author Ignacio de Tomás <[email protected]>
* @copyright 2014 Ignacio de Tomás (http://inacho.es)
*/

namespace Inacho;

class CreditCard
Expand Down Expand Up @@ -206,12 +198,12 @@ 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) ($number[$i-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) ($number[$i-1]) * 2;
if ($digit < 10) {
$checksum += $digit;
} else {
Expand Down