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