RawColorValue::getCompiled()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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 RawColorValue extends AbstractValue
19
{
20
    /**
21
     * @var string
22
     */
23
    private $value;
24
25
    /**
26
     * @inheritdoc
27
     */
28 13
    public function getCompiled()
29
    {
30 13
        if ($this->options['compressColors']) {
31 1
            return $this->compiler->compileValue($this->coerce->coerceColor(['raw_color', $this->value]));
0 ignored issues
show
Bug introduced by
It seems like $this->coerce->coerceCol..._color', $this->value)) targeting LesserPhp\Library\Coerce::coerceColor() can also be of type null; however, LesserPhp\Compiler::compileValue() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
32
        }
33
34 12
        return $this->value;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 13
    public function initializeFromOldFormat(array $value)
41
    {
42 13
        $this->value = $value[1];
43 13
    }
44
}
45