Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Digits.php
Go to the documentation of this file.
1 <?php
2 
27 #require_once 'Zend/Filter/Interface.php';
28 
29 
37 {
43  protected static $_unicodeEnabled;
44 
52  public function __construct()
53  {
54  if (null === self::$_unicodeEnabled) {
55  self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
56  }
57  }
58 
67  public function filter($value)
68  {
69  if (!self::$_unicodeEnabled) {
70  // POSIX named classes are not supported, use alternative 0-9 match
71  $pattern = '/[^0-9]/';
72  } else if (extension_loaded('mbstring')) {
73  // Filter for the value with mbstring
74  $pattern = '/[^[:digit:]]/';
75  } else {
76  // Filter for the value without mbstring
77  $pattern = '/[\p{^N}]/';
78  }
79 
80  return preg_replace($pattern, '', (string) $value);
81  }
82 }
static $_unicodeEnabled
Definition: Digits.php:43
$pattern
Definition: website.php:22
$value
Definition: gender.phtml:16
filter($value)
Definition: Digits.php:67