Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
HttpFilterableTrait | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
6 | |
100.00% |
1 / 1 |
filter | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Http; |
15 | |
16 | use Pop\Filter\FilterableTrait; |
17 | |
18 | /** |
19 | * HTTP filterable trait |
20 | * |
21 | * @category Pop |
22 | * @package Pop\Http |
23 | * @author Nick Sagona, III <dev@nolainteractive.com> |
24 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
25 | * @license http://www.popphp.org/license New BSD License |
26 | * @version 5.2.0 |
27 | */ |
28 | trait HttpFilterableTrait |
29 | { |
30 | |
31 | use FilterableTrait; |
32 | |
33 | /** |
34 | * Filter values |
35 | * |
36 | * @param mixed $values |
37 | * @return mixed |
38 | */ |
39 | public function filter(mixed $values): mixed |
40 | { |
41 | $disabledFunctions = array_filter(array_map('trim', explode(',', ini_get('disable_functions')))); |
42 | |
43 | foreach ($this->filters as $filter) { |
44 | if (is_array($values)) { |
45 | foreach ($values as $key => $value) { |
46 | if (!in_array($value, $disabledFunctions)) { |
47 | $values[$key] = $filter->filter($value, $key); |
48 | } |
49 | } |
50 | } else { |
51 | if (!in_array($values, $disabledFunctions)) { |
52 | $values = $filter->filter($values); |
53 | } |
54 | } |
55 | } |
56 | |
57 | return $values; |
58 | } |
59 | |
60 | } |