PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/DMS/Filter/Rules/Trim.php

https://github.com/phalasz/DMS
PHP | 44 lines | 17 code | 5 blank | 22 comment | 1 complexity | 71bdd3cad75bc4959af234394669f076 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. namespace DMS\Filter\Rules;
  3. /**
  4. * Trim Rule
  5. *
  6. * @package DMS
  7. * @subpackage Filter
  8. *
  9. * @Annotation
  10. */
  11. class Trim extends Rule
  12. {
  13. /**
  14. * Comma separated string of allowed tags
  15. *
  16. * @var string
  17. */
  18. public $charlist = null;
  19. /**
  20. * {@inheritDoc}
  21. */
  22. public function applyFilter($value)
  23. {
  24. //trim() only operates in default mode
  25. //if no second argument is passed, it
  26. //cannot be passed as null
  27. if ($this->charlist === null) {
  28. return trim($value);
  29. }
  30. return trim($value, $this->charlist);
  31. }
  32. /**
  33. * {@inheritDoc}
  34. */
  35. public function getDefaultOption()
  36. {
  37. return 'charlist';
  38. }
  39. }