[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/horde/framework/Horde/Support/ -> Numerizer.php (source)

   1  <?php
   2  /**
   3   * Copyright 2010-2014 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 && strtolower($locale) != 'base') {
  28              $locale = str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($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  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1