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

ListValue::initializeFromOldFormat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
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 ListValue extends AbstractValue
19
{
20
    /**
21
     * @var string
22
     */
23
    private $delimiter;
24
25
    /**
26
     * @var AbstractValue[]
27
     */
28
    private $items;
29
30
    /**
31
     * @inheritdoc
32
     */
33 22
    public function getCompiled()
34
    {
35 22
        $compiled = [];
36 22
        foreach ($this->items as $item) {
37 22
            $compiled[] = $item->getCompiled();
38
        }
39
40 22
        return implode($this->delimiter, $compiled);
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 22
    public function initializeFromOldFormat(array $value)
47
    {
48 22
        $this->delimiter = $value[1];
49 22
        $this->items     = [];
50
51 22
        foreach ($value[2] as $item) {
52 22
            $this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item);
53
        }
54 22
    }
55
}
56