Exemplo n.º 1
0
 private function validateCardNumber($card_number)
 {
     if (!$card_number) {
         return false;
     }
     //check wrong symbol in number
     if (!preg_match('/^[\\s\\d]*$/', $card_number)) {
         return false;
     }
     //delete spaces
     $card_number = preg_replace('/\\D/', '', $card_number);
     //not empty
     if ($card_number == '') {
         return false;
     }
     //check length
     if (strlen($card_number) > 20 || strlen($card_number) < 13) {
         return false;
     }
     //luhn algoritm
     $luhn = new Luhn();
     if (!$luhn->check($card_number)) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 private static function validateIsbn13($isbn13)
 {
     if (strlen($isbn13) != 13 || !ctype_digit($isbn13)) {
         return false;
     }
     return Luhn::check($isbn13, 13, false);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public static function check($gtin, $length, $unDecorate = true, $hyphens = self::HYPHENS)
 {
     return parent::check($gtin, $length, true, $hyphens);
 }