Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  /**
   3   * Copyright 2010-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * @author   Chuck Hagenbuch <chuck@horde.org>
   6   * @license  http://www.horde.org/licenses/bsd BSD
   7   * @category Horde
   8   * @package  Support
   9   */
  10  
  11  /**
  12   * @author   Chuck Hagenbuch <chuck@horde.org>
  13   * @license  http://www.horde.org/licenses/bsd BSD
  14   * @category Horde
  15   * @package  Support
  16   */
  17  class Horde_Support_Numerizer
  18  {
  19      public static function numerize($string, $args = array())
  20      {
  21          return self::factory($args)->numerize($string);
  22      }
  23  
  24      public static function factory($args = array())
  25      {
  26          $locale = isset($args['locale']) ? $args['locale'] : null;
  27          if ($locale && Horde_String::lower($locale) != 'base') {
  28              $locale = str_replace(' ', '_', Horde_String::ucwords(str_replace('_', ' ', Horde_String::lower($locale))));
  29              $class = 'Horde_Support_Numerizer_Locale_' . $locale;
  30              if (class_exists($class)) {
  31                  return new $class($args);
  32              }
  33  
  34              list($language,) = explode('_', $locale);
  35              if ($language != $locale) {
  36                  $class = 'Horde_Support_Numerizer_Locale_' . $language;
  37                  if (class_exists($class)) {
  38                      return new $class($args);
  39                  }
  40              }
  41          }
  42  
  43          return new Horde_Support_Numerizer_Locale_Base($args);
  44      }
  45  
  46  }