Razorpay\IFSC\IFSC::validate PHP Метод

validate() публичный статический Метод

public static validate ( $code )
    public static function validate($code)
    {
        self::init();
        if (strlen($code) !== 11) {
            return false;
        }
        if ($code[4] !== '0') {
            return false;
        }
        $bankCode = strtoupper(substr($code, 0, 4));
        $branchCode = strtoupper(substr($code, 5));
        if (!array_key_exists($bankCode, self::$data)) {
            return false;
        }
        $list = self::$data[$bankCode];
        if (ctype_digit($branchCode)) {
            return static::lookupNumeric($list, $branchCode);
        } else {
            return static::lookupString($list, $branchCode);
        }
    }

Usage Example

Пример #1
0
 protected function singleTest($message, $tests)
 {
     foreach ($tests as $code => $expectedValue) {
         $this->assertEquals($expectedValue, IFSC::validate($code), $message);
     }
 }