Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Less_Visitor
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
3 / 3
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 visitObj
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
4
 visitArray
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * @private
4 */
5class Less_Visitor {
6
7    protected $methods = [];
8    protected $_visitFnCache = [];
9
10    public function __construct() {
11        $this->_visitFnCache = get_class_methods( get_class( $this ) );
12        $this->_visitFnCache = array_flip( $this->_visitFnCache );
13    }
14
15    public function visitObj( $node ) {
16        $funcName = 'visit' . str_replace( [ 'Less_Tree_', '_' ], '', get_class( $node ) );
17        if ( isset( $this->_visitFnCache[$funcName] ) ) {
18            $visitDeeper = true;
19            $this->$funcName( $node, $visitDeeper );
20
21            if ( $visitDeeper ) {
22                $node->accept( $this );
23            }
24
25            $funcName .= "Out";
26            if ( isset( $this->_visitFnCache[$funcName] ) ) {
27                $this->$funcName( $node );
28            }
29
30        } else {
31            $node->accept( $this );
32        }
33
34        return $node;
35    }
36
37    public function visitArray( $nodes ) {
38        foreach ( $nodes as $node ) {
39            $this->visitObj( $node );
40        }
41        return $nodes;
42    }
43}