Passed
Pull Request — master (#5)
by
unknown
02:54
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
    private $number;
21
    private $unit;
22
23
    /**
24
     * @inheritdoc
25
     */
26 35
    public function getCompiled()
27
    {
28 35
        $num = $this->number;
29 35
        if (isset($this->options['numberPrecision'])) {
30
            $num = round($num, $this->options['numberPrecision']);
31
        }
32
33 35
        return $num.$this->unit;
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 35
    public function initializeFromOldFormat(array $value)
40
    {
41 35
        $this->number = $value[1];
42 35
        $this->unit   = $value[2];
43
    }
44
}