Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NormalizedToLocalized.php
Go to the documentation of this file.
1 <?php
25 #require_once 'Zend/Filter/Interface.php';
26 
30 #require_once 'Zend/Locale/Format.php';
31 
41 {
45  protected $_options = array(
46  'locale' => null,
47  'date_format' => null,
48  'precision' => null
49  );
50 
56  public function __construct($options = null)
57  {
58  if ($options instanceof Zend_Config) {
59  $options = $options->toArray();
60  }
61 
62  if (null !== $options) {
63  $this->setOptions($options);
64  }
65  }
66 
72  public function getOptions()
73  {
74  return $this->_options;
75  }
76 
83  public function setOptions(array $options = null)
84  {
85  $this->_options = $options + $this->_options;
86  return $this;
87  }
88 
97  public function filter($value)
98  {
99  if (is_array($value)) {
100  #require_once 'Zend/Date.php';
101  $date = new Zend_Date($value, $this->_options['locale']);
102  return $date->toString($this->_options['date_format']);
103  } else if ($this->_options['precision'] === 0) {
104  return Zend_Locale_Format::toInteger($value, $this->_options);
105  } else if ($this->_options['precision'] === null) {
106  return Zend_Locale_Format::toFloat($value, $this->_options);
107  }
108 
109  return Zend_Locale_Format::toNumber($value, $this->_options);
110  }
111 }
static toFloat($value, array $options=array())
Definition: Format.php:659
$value
Definition: gender.phtml:16
static toInteger($value, array $options=array())
Definition: Format.php:707
static toNumber($value, array $options=array())
Definition: Format.php:300