Completed
Push — master ( 6ece6a...9c4912 )
by Marcus
02:53
created

NumberValue::getCompiled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2.032
1
<?php
2
namespace LesserPhp\Compiler\Value;
3
4
/**
5
 * lesserphp
6
 * https://www.maswaba.de/lesserphp
7
 *
8
 * LESS CSS compiler, adapted from http://lesscss.org
9
 *
10
 * Copyright 2013, Leaf Corcoran <[email protected]>
11
 * Copyright 2016, Marcus Schwarz <[email protected]>
12
 * Copyright 2017, Stefan Pöhner <[email protected]>
13
 * Licensed under MIT or GPLv3, see LICENSE
14
 *
15
 * @package LesserPhp
16
 */
17
18
class NumberValue extends AbstractValue
19
{
20
    /**
21
     * @var float
22
     */
23
    private $number;
24
25
    /**
26
     * @var string
27
     */
28
    private $unit;
29
30
    /**
31
     * @inheritdoc
32
     */
33 35
    public function getCompiled()
34
    {
35 35
        $num = $this->number;
36 35
        if (isset($this->options['numberPrecision'])) {
37
            $num = round($num, $this->options['numberPrecision']);
38
        }
39
40 35
        return $num . $this->unit;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 35
    public function initializeFromOldFormat(array $value)
47
    {
48 35
        $this->number = $value[1];
49 35
        $this->unit   = $value[2];
50 35
    }
51
}
52