plugin/competency/Manager/CompetencyManager.php
public function walkCollection($collection, \Closure $callback)
    {
        if (is_array($collection)) {
            $result = [];

            foreach ($collection as $key => $item) {
                $result[$key] = $this->walkCollection($item, $callback);
            }

            return $callback($result);
        }

        return $collection;
    }
public function walkCollection($collection, \Closure $callback)
    {
        if (is_array($collection)) {
            $result = [];

            foreach ($collection as $key => $item) {
                $result[$key] = $this->walkCollection($item, $callback);
            }

            return $callback($result);
        }

        return $collection;
    }
public function walkCollection ( $ collection , \ Closure $ callback ) { if ( is_array ( $ collection ) ) { $ result = [ ] ; foreach ( $ collection as $ key => $ item ) { $ result [ $ key ] = $ this -> walkCollection ( $ item , $ callback ) ; } return $ callback ( $ result ) ; } return $ collection ; }
Utility method. Walks a collection recursively, applying a callback on
each element.

Unlike array_walk_recursive :
- the result is a *copy* of the original collection
- all the nodes are visited, not only the leafs

@param mixed    $collection
@param \Closure $callback

@return mixed
Utility method . Walks a collection recursively applying a callback on each element .