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: namespace Jyxo\Input\Filter;
15:
16: /**
17: * Filter for trimming whitespace.
18: *
19: * @category Jyxo
20: * @package Jyxo\Input
21: * @subpackage Filter
22: * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23: * @license https://github.com/jyxo/php/blob/master/license.txt
24: * @author Jan Pěček
25: * @author Jaroslav Hanslík
26: */
27: class Trim extends \Jyxo\Input\Filter\AbstractFilter
28: {
29: /**
30: * Filters a value.
31: *
32: * @param mixed $in
33: * @return mixed
34: */
35: protected function filterValue($in)
36: {
37: return trim($in);
38: }
39:
40: /**
41: * Filters a value.
42: *
43: * @param mixed $in Object to be filtered
44: * @return \Jyxo\Input\FilterInterface This object instance
45: */
46: public function filter($in)
47: {
48: $in = parent::filter($in);
49: // Removes empty values
50: if (is_array($in)) {
51: $in = array_filter($in);
52: }
53: return $in;
54: }
55: }
56: