Code Duplication    Length = 9-10 lines in 2 locations

src/tree.php 2 locations

@@ 131-140 (lines=10) @@
128
     * @param  mixed          $nodeName The name of the 'name' property or a function that returns the name of a node.
129
     * @return array
130
     */
131
    public static function ls($node, $callback, $nodeName = 'nodeName')
132
    {
133
        $result = [];
134
        foreach ($node->childNodes as $child) {
135
            $name = self::getNodeName( $child, $nodeName );
136
            $result[ $name ] = call_user_func( $callback, $child );
137
        }
138
139
        return $result;
140
    }
141
142
    /**
143
     * Calls the callback method on each child of the current node, including the node itself, until a non-null
@@ 198-206 (lines=9) @@
195
     * @param  mixed          $initial  The value to pass to the first callback call.
196
     * @return mixed
197
     */
198
    public static function reduce($node, $callback, $initial = null)
199
    {
200
        $result = call_user_func( $callback, $initial, $node );
201
        foreach ($node->childNodes as $child) {
202
            $result = self::reduce( $child, $callback, $result );
203
        }
204
205
        return $result;
206
    }
207
208
    /**
209
     * Filters the tree using a callback method. If the callback method returns true, the node's value is included