1 | <?php |
||
9 | abstract class RecursiveTransform extends Transform |
||
10 | { |
||
11 | /** |
||
12 | * Define a list of array keys `transformValue` should apply to. |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $keys = []; |
||
16 | |||
17 | /** |
||
18 | * @return array |
||
19 | */ |
||
20 | public function getKeys() |
||
24 | |||
25 | /** |
||
26 | * Apply the `transformValue` function to all values in multidementional |
||
27 | * associative array where the key matches one of the keys defined |
||
28 | * on the RecursiveTransform. |
||
29 | * @param array $config |
||
30 | * @return array transformed config |
||
31 | */ |
||
32 | public function transform($config) |
||
47 | |||
48 | |||
49 | /** |
||
50 | * @param string $key |
||
51 | * @param array $config |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function shouldTransformValue($key, $config) |
||
58 | |||
59 | /** |
||
60 | * Based upon the value or key, determine if the transform function |
||
61 | * should recurse. |
||
62 | * @param $value |
||
63 | * @param string $key |
||
64 | * @return bool |
||
65 | */ |
||
66 | protected function shouldRecurse($value, $key) |
||
70 | |||
71 | /** |
||
72 | * Impelment this in all discrete classes |
||
73 | * @param mixed $value input |
||
74 | * @return mixed output value |
||
75 | */ |
||
76 | abstract public function transformValue($value); |
||
77 | |||
78 | |||
79 | /** |
||
80 | * @param array $config |
||
81 | * @return array |
||
82 | */ |
||
83 | public function transformConfig($config) |
||
87 | } |
||
88 |