Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Zend_Validate_Iban Class Reference
Inheritance diagram for Zend_Validate_Iban:
Zend_Validate_Abstract Zend_Validate_Interface

Public Member Functions

 __construct ($locale=null)
 
 getLocale ()
 
 setLocale ($locale=null)
 
 isValid ($value)
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 
 getMessageVariables ()
 
 getMessageTemplates ()
 
 setMessage ($messageString, $messageKey=null)
 
 setMessages (array $messages)
 
 __get ($property)
 
 getErrors ()
 
 setObscureValue ($flag)
 
 getObscureValue ()
 
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 setDisableTranslator ($flag)
 
 translatorIsDisabled ()
 

Data Fields

const NOTSUPPORTED = 'ibanNotSupported'
 
const FALSEFORMAT = 'ibanFalseFormat'
 
const CHECKFAILED = 'ibanCheckFailed'
 

Protected Attributes

 $_messageTemplates
 
 $_locale
 
 $_ibanregex
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 
static getDefaultTranslator ()
 
static hasDefaultTranslator ()
 
static getMessageLength ()
 
static setMessageLength ($length=-1)
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 
 _implodeRecursive (array $pieces)
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Detailed Description

Definition at line 35 of file Iban.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $locale = null)

Sets validator options

Parameters
string | Zend_Config | Zend_Locale$localeOPTIONAL

Definition at line 137 of file Iban.php.

138  {
139  if ($locale instanceof Zend_Config) {
140  $locale = $locale->toArray();
141  }
142 
143  if (is_array($locale)) {
144  if (array_key_exists('locale', $locale)) {
145  $locale = $locale['locale'];
146  } else {
147  $locale = null;
148  }
149  }
150 
151  if (empty($locale)) {
152  #require_once 'Zend/Registry.php';
153  if (Zend_Registry::isRegistered('Zend_Locale')) {
154  $locale = Zend_Registry::get('Zend_Locale');
155  }
156  }
157 
158  if ($locale !== null) {
159  $this->setLocale($locale);
160  }
161  }
setLocale($locale=null)
Definition: Iban.php:181
static isRegistered($index)
Definition: Registry.php:178
static get($index)
Definition: Registry.php:141

Member Function Documentation

◆ getLocale()

getLocale ( )

Returns the locale option

Returns
string|Zend_Locale|null

Definition at line 168 of file Iban.php.

169  {
170  return $this->_locale;
171  }

◆ isValid()

isValid (   $value)

Defined by Zend_Validate_Interface

Returns true if $value is a valid IBAN

Parameters
string$value
Returns
boolean

Implements Zend_Validate_Interface.

Definition at line 204 of file Iban.php.

205  {
206  $value = strtoupper($value);
207  $this->_setValue($value);
208 
209  if (empty($this->_locale)) {
210  $region = substr($value, 0, 2);
211  } else {
212  $region = new Zend_Locale($this->_locale);
213  $region = $region->getRegion();
214  }
215 
216  if (!array_key_exists($region, $this->_ibanregex)) {
217  $this->_setValue($region);
218  $this->_error(self::NOTSUPPORTED);
219  return false;
220  }
221 
222  if (!preg_match($this->_ibanregex[$region], $value)) {
223  $this->_error(self::FALSEFORMAT);
224  return false;
225  }
226 
227  $format = substr($value, 4) . substr($value, 0, 4);
228  $format = str_replace(
229  array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
230  'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'),
231  array('10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22',
232  '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'),
233  $format);
234 
235  $temp = intval(substr($format, 0, 1));
236  $len = strlen($format);
237  for ($x = 1; $x < $len; ++$x) {
238  $temp *= 10;
239  $temp += intval(substr($format, $x, 1));
240  $temp %= 97;
241  }
242 
243  if ($temp != 1) {
244  $this->_error(self::CHECKFAILED);
245  return false;
246  }
247 
248  return true;
249  }
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16
$format
Definition: list.phtml:12

◆ setLocale()

setLocale (   $locale = null)

Sets the locale option

Parameters
string | Zend_Locale$locale
Exceptions
Zend_Locale_Exception
Zend_Validate_Exception
Returns
Zend_Validate_Date provides a fluent interface

Definition at line 181 of file Iban.php.

182  {
183  if ($locale !== false) {
184  #require_once 'Zend/Locale.php';
185  $locale = Zend_Locale::findLocale($locale);
186  if (strlen($locale) < 4) {
187  #require_once 'Zend/Validate/Exception.php';
188  throw new Zend_Validate_Exception('Region must be given for IBAN validation');
189  }
190  }
191 
192  $this->_locale = $locale;
193  return $this;
194  }
static findLocale($locale=null)
Definition: Locale.php:1740

Field Documentation

◆ $_ibanregex

$_ibanregex
protected

Definition at line 64 of file Iban.php.

◆ $_locale

$_locale
protected

Definition at line 57 of file Iban.php.

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::NOTSUPPORTED => "Unknown country within the IBAN '%value%'",
self::FALSEFORMAT => "'%value%' has a false IBAN format",
self::CHECKFAILED => "'%value%' has failed the IBAN check",
)

Definition at line 46 of file Iban.php.

◆ CHECKFAILED

const CHECKFAILED = 'ibanCheckFailed'

Definition at line 39 of file Iban.php.

◆ FALSEFORMAT

const FALSEFORMAT = 'ibanFalseFormat'

Definition at line 38 of file Iban.php.

◆ NOTSUPPORTED

const NOTSUPPORTED = 'ibanNotSupported'

Definition at line 37 of file Iban.php.


The documentation for this class was generated from the following file: