| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | protected static function applyRecursively(array $data, Closure $callback) |
||
| 22 | { |
||
| 23 | /* Initialize the RecursiveArrayIterator for the provided data */ |
||
| 24 | $arrayIterator = new RecursiveArrayIterator($data); |
||
| 25 | |||
| 26 | /* Configure the Iterator for the RecursiveIterator */ |
||
| 27 | $recursiveIterator = new RecursiveIteratorIterator( |
||
| 28 | $arrayIterator, |
||
| 29 | RecursiveIteratorIterator::SELF_FIRST |
||
| 30 | ); |
||
| 31 | |||
| 32 | /* Traverse the provided data */ |
||
| 33 | foreach ($recursiveIterator as $key => $value) { |
||
| 34 | /* Get the current sub iterator with Type hinting */ |
||
| 35 | /** @var RecursiveArrayIterator */ |
||
| 36 | $subIterator = $recursiveIterator->getSubIterator(); |
||
| 37 | |||
| 38 | /* Process the element with the provided closure */ |
||
| 39 | $callback($value, $key, $subIterator); |
||
| 40 | |||
| 41 | /* Update (possibly) changed value */ |
||
| 42 | $subIterator->offsetSet($key, $value); |
||
|
|
|||
| 43 | } |
||
| 44 | |||
| 45 | /* Return the processed data */ |
||
| 46 | return $arrayIterator->getArrayCopy(); |
||
| 47 | } |
||
| 49 |