From ead0c004b64321ac18fc33e20a5771318883bd89 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 1 Jul 2013 00:10:46 +0300 Subject: [PATCH] minor fixes --- ipf/orm/validator/country.php | 3 ++- ipf/orm/validator/creditcard.php | 16 +++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ipf/orm/validator/country.php b/ipf/orm/validator/country.php index 2536f15..966ede8 100644 --- a/ipf/orm/validator/country.php +++ b/ipf/orm/validator/country.php @@ -257,4 +257,5 @@ class IPF_ORM_Validator_Country $value = strtolower($value); return isset(self::$countries[$value]); } -} \ No newline at end of file +} + diff --git a/ipf/orm/validator/creditcard.php b/ipf/orm/validator/creditcard.php index f4a59f6..62609ac 100644 --- a/ipf/orm/validator/creditcard.php +++ b/ipf/orm/validator/creditcard.php @@ -4,7 +4,6 @@ class IPF_ORM_Validator_Creditcard { public function validate($value) { - $cardType = ""; $card_regexes = array( "/^4\d{12}(\d\d\d){0,1}$/" => 'visa', "/^5[12345]\d{14}$/" => 'mastercard', @@ -13,15 +12,17 @@ class IPF_ORM_Validator_Creditcard "/^30[012345]\d{11}$/" => 'diners', "/^3[68]\d{12}$/" => 'diners', ); + + $cardType = ''; foreach ($card_regexes as $regex => $type) { if (preg_match($regex, $value)) { $cardType = $type; break; } } - if ( ! $cardType) { + if (!$cardType) return false; - } + /* mod 10 checksum algorithm */ $revcode = strrev($value); $checksum = 0; @@ -36,10 +37,7 @@ class IPF_ORM_Validator_Creditcard $checksum += 1; } } - if ($checksum % 10 == 0) { - return true; - } else { - return false; - } + return $checksum % 10 == 0; } -} \ No newline at end of file +} + -- 2.49.0