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

Public Member Functions

 __construct ($allowWhiteSpace=false)
 
 getAllowWhiteSpace ()
 
 setAllowWhiteSpace ($allowWhiteSpace)
 
 filter ($value)
 

Data Fields

 $allowWhiteSpace
 

Protected Attributes

 $_locale
 

Static Protected Attributes

static $_unicodeEnabled
 
static $_meansEnglishAlphabet
 

Detailed Description

Definition at line 37 of file Alnum.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $allowWhiteSpace = false)

Sets default option values for this instance

Parameters
boolean$allowWhiteSpace
Returns
void

Definition at line 74 of file Alnum.php.

75  {
76  if ($allowWhiteSpace instanceof Zend_Config) {
78  } else if (is_array($allowWhiteSpace)) {
79  if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
80  $allowWhiteSpace = $allowWhiteSpace['allowwhitespace'];
81  } else {
82  $allowWhiteSpace = false;
83  }
84  }
85 
86  $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
87  if (null === self::$_unicodeEnabled) {
88  self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
89  }
90 
91  if (null === self::$_meansEnglishAlphabet) {
92  $this->_locale = new Zend_Locale('auto');
93  self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(),
94  array('ja', 'ko', 'zh')
95  );
96  }
97 
98  }

Member Function Documentation

◆ filter()

filter (   $value)

Defined by Zend_Filter_Interface

Returns the string $value, removing all but alphabetic and digit characters

Parameters
string$value
Returns
string

Implements Zend_Filter_Interface.

Definition at line 130 of file Alnum.php.

131  {
132  $whiteSpace = $this->allowWhiteSpace ? '\s' : '';
133  if (!self::$_unicodeEnabled) {
134  // POSIX named classes are not supported, use alternative a-zA-Z0-9 match
135  $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/';
136  } else if (self::$_meansEnglishAlphabet) {
137  //The Alphabet means english alphabet.
138  $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u';
139  } else {
140  //The Alphabet means each language's alphabet.
141  $pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u';
142  }
143 
144  return preg_replace($pattern, '', (string) $value);
145  }
$pattern
Definition: website.php:22
$value
Definition: gender.phtml:16

◆ getAllowWhiteSpace()

getAllowWhiteSpace ( )

Returns the allowWhiteSpace option

Returns
boolean

Definition at line 105 of file Alnum.php.

106  {
107  return $this->allowWhiteSpace;
108  }

◆ setAllowWhiteSpace()

setAllowWhiteSpace (   $allowWhiteSpace)

Sets the allowWhiteSpace option

Parameters
boolean$allowWhiteSpace
Returns
Zend_Filter_Alnum Provides a fluent interface

Definition at line 116 of file Alnum.php.

117  {
118  $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
119  return $this;
120  }

Field Documentation

◆ $_locale

$_locale
protected

Definition at line 59 of file Alnum.php.

◆ $_meansEnglishAlphabet

$_meansEnglishAlphabet
staticprotected

Definition at line 66 of file Alnum.php.

◆ $_unicodeEnabled

$_unicodeEnabled
staticprotected

Definition at line 52 of file Alnum.php.

◆ $allowWhiteSpace

$allowWhiteSpace

Definition at line 45 of file Alnum.php.


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