PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zym/Filter/Sprintf.php

https://bitbucket.org/cssw/cssw-cms
PHP | 84 lines | 25 code | 6 blank | 53 comment | 1 complexity | a1f58c120f69656db19bc626c06dedcc MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Zym Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. *
  10. * @category Zym
  11. * @package Zym_Filter
  12. * @copyright Copyright (c) 2008 Zym. (http://www.zym-project.com/)
  13. * @license http://www.zym-project.com/license New BSD License
  14. */
  15. /**
  16. * @see Zend_Filter_Interface
  17. */
  18. require_once 'Zend/Filter/Interface.php';
  19. /**
  20. * Filter using sprintf
  21. *
  22. * @author Geoffrey Tran
  23. * @license http://www.zym-project.com/license New BSD License
  24. * @category Zym
  25. * @package Zym_Filter
  26. * @copyright Copyright (c) 2008 Zym. (http://www.zym-project.com/)
  27. */
  28. class Zym_Filter_Sprintf implements Zend_Filter_Interface
  29. {
  30. /**
  31. * Sprintf args
  32. *
  33. * @var array
  34. */
  35. protected $_args = array();
  36. /**
  37. * Construct
  38. *
  39. * @param [, mixed $args [, mixed $...]]
  40. */
  41. public function __construct()
  42. {
  43. if (func_num_args()) {
  44. call_user_func_array(array($this, 'setArgs'), func_get_args());
  45. }
  46. }
  47. /**
  48. * Set args
  49. *
  50. * @param [, mixed $args [, mixed $...]]
  51. * @return Zym_Filter_Sprintf
  52. */
  53. public function setArgs()
  54. {
  55. $this->_args = func_get_args();
  56. return $this;
  57. }
  58. /**
  59. * Get args
  60. *
  61. * @return array
  62. */
  63. public function getArgs()
  64. {
  65. return $this->_args;
  66. }
  67. /**
  68. * Returns the result of filtering $value
  69. *
  70. * @param string $value
  71. * @throws Zend_Filter_Exception If filtering $value is impossible
  72. * @return string
  73. */
  74. public function filter($value)
  75. {
  76. return call_user_func_array('sprintf', array_merge(array((string) $value), $this->getArgs()));
  77. }
  78. }