1: <?php
2:
3: /**
4: * Jyxo PHP Library
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file license.txt.
10: * It is also available through the world-wide-web at this URL:
11: * https://github.com/jyxo/php/blob/master/license.txt
12: */
13:
14: /**
15: * Filter for trimming whitespace.
16: *
17: * @category Jyxo
18: * @package Jyxo_Input
19: * @subpackage Filter
20: * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
21: * @license https://github.com/jyxo/php/blob/master/license.txt
22: * @author Jan Pěček
23: * @author Jaroslav Hanslík
24: */
25: class Jyxo_Input_Filter_Trim extends Jyxo_Input_Filter_AbstractFilter
26: {
27: /**
28: * Filters a value.
29: *
30: * @param mixed $in
31: * @return mixed
32: */
33: protected function filterValue($in)
34: {
35: return trim($in);
36: }
37:
38: /**
39: * Filters a value.
40: *
41: * @param mixed $in Object to be filtered
42: * @return Jyxo_Input_FilterInterface This object instance
43: */
44: public function filter($in)
45: {
46: $in = parent::filter($in);
47: // Removes empty values
48: if (is_array($in)) {
49: $in = array_filter($in);
50: }
51: return $in;
52: }
53: }
54: