Passed
Pull Request — master (#5)
by
unknown
02:54
created

StringValue::getCompiled()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
crap 3
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 StringValue extends AbstractValue
19
{
20
    private $delimiter;
21
    private $content;
22
23
    /**
24
     * @inheritdoc
25
     */
26 27
    public function getCompiled()
27
    {
28 27
        $content = $this->content;
29 27
        foreach ($content as &$part) {
30 27
            if (is_array($part)) {
31 27
                $part = $this->compiler->compileValue($part);
32
            }
33
        }
34
35 27
        return $this->delimiter.implode($content).$this->delimiter;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 27
    public function initializeFromOldFormat(array $value)
42
    {
43 27
        $this->delimiter = $value[1];
44 27
        $this->content   = $value[2];
45
    }
46
}