LocalizedNumeric.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ YiS2qE8mFFUB1lpn9ufd2/gZfLszl9WpY+Szb5+Qd34=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2017 Online Ventures Software & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.9 [rev.7.9.01]
  11. */
  12. /**
  13. * localized numeric number filter
  14. */
  15. namespace Ppb\Filter;
  16. use Cube\Filter\AbstractFilter,
  17. Cube\Locale\Format as LocaleFormat;
  18. class LocalizedNumeric extends AbstractFilter
  19. {
  20. /**
  21. *
  22. * replace a localized numeric format with a standard number
  23. * accepts arrays as well, and will convert to numeric each localized numeric value
  24. *
  25. * @param mixed $value
  26. *
  27. * @return mixed
  28. */
  29. public function filter($value)
  30. {
  31. if (is_array($value)) {
  32. array_walk_recursive($value, function (&$element) {
  33. if (!is_array($element)) {
  34. $element = LocaleFormat::getInstance()->localizedToNumeric($element, true);
  35. }
  36. });
  37. return $value;
  38. }
  39. return LocaleFormat::getInstance()->localizedToNumeric($value, true);
  40. }
  41. }