1 | <?php namespace Arcanedev\Sanitizer; |
||
12 | class Factory |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * List of custom filters |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $filters = []; |
||
24 | |||
25 | /* ------------------------------------------------------------------------------------------------ |
||
26 | | Constructor |
||
27 | | ------------------------------------------------------------------------------------------------ |
||
28 | */ |
||
29 | /** |
||
30 | * Create a new instance. |
||
31 | * |
||
32 | * @param array $filters |
||
33 | */ |
||
34 | 90 | public function __construct(array $filters = []) |
|
38 | |||
39 | /* ------------------------------------------------------------------------------------------------ |
||
40 | | Main Functions |
||
41 | | ------------------------------------------------------------------------------------------------ |
||
42 | */ |
||
43 | /** |
||
44 | * Make a sanitizer |
||
45 | * |
||
46 | * @param array $data |
||
47 | * @param array $rules |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | 36 | public function make(array $data, array $rules) |
|
55 | |||
56 | /** |
||
57 | * Add a custom filters to all Sanitizers created with this Factory. |
||
58 | * |
||
59 | * @param string $name |
||
60 | * @param \Closure|Filterable|string $filter |
||
61 | * |
||
62 | * @throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException |
||
63 | */ |
||
64 | 54 | public function extend($name, $filter) |
|
74 | |||
75 | /* ------------------------------------------------------------------------------------------------ |
||
76 | | Check Functions |
||
77 | | ------------------------------------------------------------------------------------------------ |
||
78 | */ |
||
79 | /** |
||
80 | * Check the filter name. |
||
81 | * |
||
82 | * @param string $name |
||
83 | * |
||
84 | * @throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException |
||
85 | */ |
||
86 | 54 | private function checkName($name) |
|
94 | |||
95 | /** |
||
96 | * Check if filter is filterable. |
||
97 | * |
||
98 | * @param mixed $filter |
||
99 | * |
||
100 | * @throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException |
||
101 | */ |
||
102 | 27 | private function isFilterable($filter) |
|
116 | } |
||
117 |