Example #1
0
 /**
  * Sets default option values for this instance
  *
  * @param array|Traversable|bool|null $allowWhiteSpaceOrOptions
  * @param string|null $locale
  */
 public function __construct($allowWhiteSpaceOrOptions = null, $locale = null)
 {
     parent::__construct();
     if ($allowWhiteSpaceOrOptions !== null) {
         if (static::isOptions($allowWhiteSpaceOrOptions)) {
             $this->setOptions($allowWhiteSpaceOrOptions);
         } else {
             $this->setAllowWhiteSpace($allowWhiteSpaceOrOptions);
             $this->setLocale($locale);
         }
     }
 }
Example #2
0
 /**
  * @param array|Traversable|string|null $localeOrOptions
  * @param int  $style
  * @param int  $type
  */
 public function __construct($localeOrOptions = null, $style = NumberFormatter::DEFAULT_STYLE, $type = NumberFormatter::TYPE_DOUBLE)
 {
     parent::__construct();
     if ($localeOrOptions !== null) {
         if ($localeOrOptions instanceof Traversable) {
             $localeOrOptions = iterator_to_array($localeOrOptions);
         }
         if (!is_array($localeOrOptions)) {
             $this->setLocale($localeOrOptions);
             $this->setStyle($style);
             $this->setType($type);
         } else {
             $this->setOptions($localeOrOptions);
         }
     }
 }
Example #3
0
 /**
  * Set the locale.
  *
  * @param  string|null $locale
  * @return $this
  */
 public function setLocale($locale = null)
 {
     $this->formatter = null;
     return parent::setLocale($locale);
 }