Skip to content
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 <nacho@inacho.es>
* @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