1 | <?php |
||
20 | final class StaticFilter |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var array List of available filter |
||
25 | */ |
||
26 | public static $filters = [ |
||
27 | 'text' => 'Slick\Filter\Text', |
||
28 | 'htmlEntities' => 'Slick\Filter\HtmlEntities', |
||
29 | 'number' => 'Slick\Filter\Number', |
||
30 | 'url' => 'Slick\Filter\Url' |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Creates the filter in the alias or class name and applies it to the |
||
35 | * provided value. |
||
36 | * |
||
37 | * @param string $alias Filter alias or FQ class name |
||
38 | * @param mixed $value Value to filter |
||
39 | * |
||
40 | * @throws InvalidArgumentException If the class does not exists or if |
||
41 | * class does not implements the FilterInterface. |
||
42 | * |
||
43 | * @return mixed |
||
44 | */ |
||
45 | 2 | public static function filter($alias, $value) |
|
50 | |||
51 | /** |
||
52 | * Creates the filter object for provided alias or FQ class name |
||
53 | * |
||
54 | * @param string $filter Filter alias od FQ class name |
||
55 | * |
||
56 | * @throws InvalidArgumentException If the class does not exists or if |
||
57 | * class does not implements the FilterInterface. |
||
58 | * |
||
59 | * @return FilterInterface |
||
60 | */ |
||
61 | 8 | public static function create($filter) |
|
67 | |||
68 | /** |
||
69 | * Returns the class name for provided alias |
||
70 | * |
||
71 | * @param string $alias The FQ class name or one of known filter alias |
||
72 | * @return string |
||
73 | * |
||
74 | * @throws InvalidArgumentException If the class does not exists. |
||
75 | */ |
||
76 | 8 | protected static function getClass($alias) |
|
89 | |||
90 | /** |
||
91 | * Verifies is provided class implements the FilterInterface interface |
||
92 | * |
||
93 | * @param string $class |
||
94 | * |
||
95 | * @throws InvalidArgumentException |
||
96 | * If the class does not implements the interface. |
||
97 | */ |
||
98 | 6 | protected static function checkFilter($class) |
|
107 | } |
||
108 |