Completed
Pull Request — master (#5)
by
unknown
02:59
created

ListValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCompiled() 0 9 2
A initializeFromOldFormat() 0 9 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
	private $delimiter;
21
	/** @var AbstractValue[] */
22
	private $items;
23
24
	/**
25
	 * @inheritdoc
26
	 */
27 22
	public function getCompiled()
28
	{
29 22
		$compiled = [];
30 22
		foreach ($this->items as $item) {
31 22
			$compiled[] = $item->getCompiled();
32
		}
33
34 22
		return implode($this->delimiter, $compiled);
35
	}
36
37
	/**
38
	 * @inheritdoc
39
	 */
40 22
	public function initializeFromOldFormat(array $value)
41
	{
42 22
		$this->delimiter = $value[1];
43 22
		$this->items     = [];
44
45 22
		foreach ($value[2] as $item) {
46 22
			$this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item);
47
		}
48
	}
49
}