| 1 | <?php |
||
| 14 | abstract class FilterRule |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string|null |
||
| 18 | */ |
||
| 19 | protected $encodingFormat; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var bool |
||
| 23 | */ |
||
| 24 | protected $allowNotSet = false; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var bool |
||
| 28 | */ |
||
| 29 | protected $isEmpty = false; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array|null |
||
| 33 | */ |
||
| 34 | protected $filterData; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param string|null $encodingFormat |
||
| 38 | */ |
||
| 39 | 191 | public function setEncodingFormat($encodingFormat) |
|
| 40 | { |
||
| 41 | 191 | $this->encodingFormat = $encodingFormat; |
|
| 42 | 191 | } |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Set the value to empty |
||
| 46 | * |
||
| 47 | * @return null |
||
| 48 | */ |
||
| 49 | 7 | protected function setEmpty() |
|
| 50 | { |
||
| 51 | 7 | $this->isEmpty = true; |
|
| 52 | 7 | return null; |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | 188 | public function isNotEmpty() |
|
| 59 | { |
||
| 60 | 188 | return !$this->isEmpty; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param array|null $filterData |
||
| 65 | */ |
||
| 66 | 191 | public function setFilterData($filterData) |
|
| 67 | { |
||
| 68 | 191 | $this->filterData = $filterData; |
|
| 69 | |||
| 70 | // Make sure that the value is not empty by default |
||
| 71 | 191 | $this->isEmpty = false; |
|
| 72 | 191 | } |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @return array|null |
||
| 76 | */ |
||
| 77 | 5 | public function getFilterData() |
|
| 78 | { |
||
| 79 | 5 | return $this->filterData; |
|
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return bool |
||
| 84 | */ |
||
| 85 | 15 | public function allowedNotSet() |
|
| 86 | { |
||
| 87 | 15 | return $this->allowNotSet; |
|
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @param mixed $value |
||
| 92 | * @return mixed |
||
| 93 | */ |
||
| 94 | abstract public function filter($value); |
||
| 95 | } |
||
| 96 |