From: Andrey Kutejko Date: Sun, 30 Jun 2013 21:10:46 +0000 (+0300) Subject: minor fixes X-Git-Tag: 0.6~103 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=ead0c004b64321ac18fc33e20a5771318883bd89;p=ipf-legacy-orm.git minor fixes --- 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 +} +