| 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) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Based upon the value or key, determine if the transform function |
||
| 49 | * should recurse. |
||
| 50 | * @param $value |
||
| 51 | * @param string $key |
||
| 52 | * @return bool |
||
| 53 | */ |
||
| 54 | protected function shouldRecurse($value, $key) |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Impelment this in all discrete classes |
||
| 61 | * @param mixed $value input |
||
| 62 | * @return mixed output value |
||
| 63 | */ |
||
| 64 | abstract public function transformValue($value); |
||
| 65 | } |
||
| 66 |