Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Less_VisitorReplacing | |
100.00% |
17 / 17 |
|
100.00% |
2 / 2 |
9 | |
100.00% |
1 / 1 |
visitArray | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |||
flatten | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
5 |
1 | <?php |
2 | /** |
3 | * @private |
4 | */ |
5 | class Less_VisitorReplacing extends Less_Visitor { |
6 | |
7 | public function visitArray( &$nodes ) { |
8 | $newNodes = []; |
9 | foreach ( $nodes as $node ) { |
10 | $evald = $this->visitObj( $node ); |
11 | if ( $evald ) { |
12 | if ( is_array( $evald ) ) { |
13 | self::flatten( $evald, $newNodes ); |
14 | } else { |
15 | $newNodes[] = $evald; |
16 | } |
17 | } |
18 | } |
19 | return $newNodes; |
20 | } |
21 | |
22 | public function flatten( $arr, &$out ) { |
23 | foreach ( $arr as $item ) { |
24 | if ( !is_array( $item ) ) { |
25 | $out[] = $item; |
26 | continue; |
27 | } |
28 | |
29 | foreach ( $item as $nestedItem ) { |
30 | if ( is_array( $nestedItem ) ) { |
31 | self::flatten( $nestedItem, $out ); |
32 | } else { |
33 | $out[] = $nestedItem; |
34 | } |
35 | } |
36 | } |
37 | |
38 | return $out; |
39 | } |
40 | |
41 | } |