PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/koowa/filter/dirname.php

https://github.com/stipsan/nooku-server
PHP | 43 lines | 14 code | 2 blank | 27 comment | 0 complexity | ac3ded3637968c590b9a9b52482c46a4 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @category Koowa
  5. * @package Koowa_Filter
  6. * @copyright Copyright (C) 2007 - 2010 Johan Janssens. All rights reserved.
  7. * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
  8. * @link http://www.nooku.org
  9. */
  10. /**
  11. * Dirname filter
  12. *
  13. * @author Johan Janssens <johan@nooku.org>
  14. * @category Koowa
  15. * @package Koowa_Filter
  16. */
  17. class KFilterDirname extends KFilterAbstract
  18. {
  19. /**
  20. * Validate a value
  21. *
  22. * @param scalar Variable to be validated
  23. * @return bool True when the variable is valid
  24. */
  25. protected function _validate($value)
  26. {
  27. $value = trim($value);
  28. return ((string) $value === $this->sanitize($value));
  29. }
  30. /**
  31. * Sanitize a value
  32. *
  33. * @param scalar Variable to be sanitized
  34. * @return string
  35. */
  36. protected function _sanitize($value)
  37. {
  38. $value = trim($value);
  39. return dirname($value);
  40. }
  41. }