Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
94.12% |
16 / 17 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
Less_Tree_Attribute | |
94.12% |
16 / 17 |
|
75.00% |
3 / 4 |
10.02 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
compile | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
5 | |||
genCSS | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toCSS | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | /** |
3 | * @private |
4 | */ |
5 | class Less_Tree_Attribute extends Less_Tree implements Less_Tree_HasValueProperty { |
6 | |
7 | public $key; |
8 | public $op; |
9 | public $value; |
10 | |
11 | public function __construct( $key, $op, $value ) { |
12 | $this->key = $key; |
13 | $this->op = $op; |
14 | $this->value = $value; |
15 | } |
16 | |
17 | public function compile( $env ) { |
18 | $key_obj = is_object( $this->key ); |
19 | $val_obj = is_object( $this->value ); |
20 | |
21 | if ( !$key_obj && !$val_obj ) { |
22 | return $this; |
23 | } |
24 | |
25 | return new self( |
26 | $key_obj ? $this->key->compile( $env ) : $this->key, |
27 | $this->op, |
28 | $val_obj ? $this->value->compile( $env ) : $this->value ); |
29 | } |
30 | |
31 | /** |
32 | * @see Less_Tree::genCSS |
33 | */ |
34 | public function genCSS( $output ) { |
35 | $output->add( $this->toCSS() ); |
36 | } |
37 | |
38 | public function toCSS() { |
39 | $value = $this->key; |
40 | |
41 | if ( $this->op ) { |
42 | $value .= $this->op; |
43 | $value .= ( is_object( $this->value ) ? $this->value->toCSS() : $this->value ); |
44 | } |
45 | |
46 | return '[' . $value . ']'; |
47 | } |
48 | } |