Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
85.71% covered (warning)
85.71%
6 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
Less_Tree_Anonymous
92.86% covered (success)
92.86%
13 / 14
85.71% covered (warning)
85.71%
6 / 7
13.06
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 compile
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 compare
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
12
 isRulesetLike
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 genCSS
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
 markReferenced
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIsReferenced
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2/**
3 * @private
4 * @see less-2.5.3.js#Anonymous.prototype
5 */
6class Less_Tree_Anonymous extends Less_Tree implements Less_Tree_HasValueProperty {
7    /** @var string */
8    public $value;
9    /** @var string|null */
10    public $quote;
11    /** @var int|null */
12    public $index;
13    /** @var bool|null */
14    public $mapLines;
15    /** @var array|null */
16    public $currentFileInfo;
17    /** @var bool */
18    public $rulesetLike;
19    /** @var bool */
20    public $isReferenced;
21
22    /**
23     * @param string $value
24     * @param int|null $index
25     * @param array|null $currentFileInfo
26     * @param bool|null $mapLines
27     * @param bool $rulesetLike
28     * @param bool $referenced
29     */
30    public function __construct( $value, $index = null, $currentFileInfo = null, $mapLines = null, $rulesetLike = false, $referenced = false ) {
31        $this->value = $value;
32        $this->index = $index;
33        $this->mapLines = $mapLines;
34        $this->currentFileInfo = $currentFileInfo;
35        $this->rulesetLike = $rulesetLike;
36        // TODO: remove isReferenced and implement $visibilityInfo
37        // https://github.com/less/less.js/commit/ead3e29f7b79390ad3ac798bf42195b24919107d
38        $this->isReferenced = $referenced;
39    }
40
41    public function compile( $env ) {
42        return new self( $this->value, $this->index, $this->currentFileInfo, $this->mapLines, $this->rulesetLike, $this->isReferenced );
43    }
44
45    /**
46     * @param Less_Tree|mixed $x
47     * @return int|null
48     * @see less-3.13.1.js#Anonymous.prototype.compare
49     */
50    public function compare( $x ) {
51        return ( $x instanceof Less_Tree && $this->toCSS() === $x->toCSS() ) ? 0 : null;
52    }
53
54    public function isRulesetLike() {
55        return $this->rulesetLike;
56    }
57
58    /**
59     * @see less-3.13.1.js#Anonymous.prototype.genCSS
60     */
61    public function genCSS( $output ) {
62        $this->nodeVisible = $this->value !== "" && $this->value !== 0;
63        if ( $this->nodeVisible ) {
64            $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines );
65        }
66    }
67
68    public function markReferenced() {
69        $this->isReferenced = true;
70    }
71
72    public function getIsReferenced() {
73        return !isset( $this->currentFileInfo['reference'] ) || !$this->currentFileInfo['reference'] || $this->isReferenced;
74    }
75}