[TASK] Remove old language labels in EXT:setup
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Filter / TrimFilter.php
1 <?php
2 namespace TYPO3\CMS\Form\Domain\Filter;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Trim filter
19 */
20 class TrimFilter extends AbstractFilter implements FilterInterface
21 {
22 /**
23 * Characters used by trim filter
24 *
25 * @var string
26 */
27 protected $characterList;
28
29 /**
30 * Constructor
31 *
32 * @param array $arguments Filter configuration
33 */
34 public function __construct(array $arguments = [])
35 {
36 $this->setCharacterList($arguments['characterList']);
37 }
38
39 /**
40 * Set the characters that need to be stripped from the
41 * beginning or the end of the input,
42 * in addition to the default trim characters
43 *
44 * @param string $characterList
45 * @return void
46 */
47 public function setCharacterList($characterList)
48 {
49 $this->characterList = $characterList;
50 }
51
52 /**
53 * Return filtered value
54 * Strip characters from the beginning and the end
55 *
56 * @param string $value
57 * @return string
58 */
59 public function filter($value)
60 {
61 if (
62 $this->characterList === null
63 || $this->characterList === ''
64 ) {
65 return trim((string)$value);
66 } else {
67 return trim((string)$value, $this->characterList);
68 }
69 }
70 }