Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • AbstractValidator
  • Callback
  • Equals
  • InArray
  • IsArray
  • IsBankAccountNumber
  • IsBirthNumber
  • IsCompanyId
  • IsCountryCode
  • IsDate
  • IsDateTime
  • IsEmail
  • IsIban
  • IsInt
  • IsIpV4
  • IsIpV6
  • IsNumeric
  • IsPhone
  • IsTaxId
  • IsUrl
  • IsZipCode
  • LessThan
  • NotEmpty
  • Regex
  • StringLengthBetween
  • StringLengthGreaterThan
  • StringLengthLessThan
  • Upload

Interfaces

  • ErrorMessage

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: namespace Jyxo\Input\Validator;
15: 
16: /**
17:  * (Czech) IBAN number validator.
18:  *
19:  * @category Jyxo
20:  * @package Jyxo\Input
21:  * @subpackage Validator
22:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23:  * @license https://github.com/jyxo/php/blob/master/license.txt
24:  * @author Jaroslav HanslĂ­k
25:  */
26: class IsIban extends \Jyxo\Input\Validator\AbstractValidator
27: {
28:     /**
29:      * Validates a value.
30:      *
31:      * @param mixed $value Input value
32:      * @return boolean
33:      */
34:     public function isValid($value)
35:     {
36:         // Removes spaces
37:         $iban = preg_replace('~\s+~', '', (string) $value);
38: 
39:         if (!preg_match('~^CZ(\d{2})(\d{4})(\d{6})(\d{10})$~i', $iban, $matches)) {
40:             return false;
41:         }
42: 
43:         list(, $control, $bankCode, $prefix, $base) = $matches;
44: 
45:         // Bank account number check
46:         if (!\Jyxo\Input\Validator::isBankAccountNumber(sprintf('%s-%s/%s', $prefix, $base, $bankCode))) {
47:             return false;
48:         }
49: 
50:         // Control code check
51:         $temp = $bankCode . $prefix . $base . '1235' . $control;    // 1235 = CZ
52:         $mod = (int) substr($temp, 0, 9) % 97;
53:         $mod = (int) ($mod . substr($temp, 9, 7)) % 97;
54:         $mod = (int) ($mod . substr($temp, 16, 7)) % 97;
55:         $mod = (int) ($mod . substr($temp, 23)) % 97;
56:         if (1 !== $mod) {
57:             return false;
58:         }
59: 
60:         return true;
61:     }
62: }
63: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0