Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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  }