@@ -17,21 +17,21 @@ |
||
17 | 17 | |
18 | 18 | class KeywordValue extends AbstractValue |
19 | 19 | { |
20 | - private $keyword; |
|
20 | + private $keyword; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - return $this->keyword; |
|
28 | - } |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + return $this->keyword; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @inheritdoc |
|
32 | - */ |
|
33 | - public function initializeFromOldFormat(array $value) |
|
34 | - { |
|
35 | - $this->keyword = $value[1]; |
|
36 | - } |
|
30 | + /** |
|
31 | + * @inheritdoc |
|
32 | + */ |
|
33 | + public function initializeFromOldFormat(array $value) |
|
34 | + { |
|
35 | + $this->keyword = $value[1]; |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -17,25 +17,25 @@ |
||
17 | 17 | |
18 | 18 | class RawColorValue extends AbstractValue |
19 | 19 | { |
20 | - private $value; |
|
20 | + private $value; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - if ($this->options['compressColors']) { |
|
28 | - return $this->compiler->compileValue($this->coerce->coerceColor(['raw_color', $this->value])); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + if ($this->options['compressColors']) { |
|
28 | + return $this->compiler->compileValue($this->coerce->coerceColor(['raw_color', $this->value])); |
|
29 | + } |
|
30 | 30 | |
31 | - return $this->value; |
|
32 | - } |
|
31 | + return $this->value; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @inheritdoc |
|
36 | - */ |
|
37 | - public function initializeFromOldFormat(array $value) |
|
38 | - { |
|
39 | - $this->value = $value[1]; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @inheritdoc |
|
36 | + */ |
|
37 | + public function initializeFromOldFormat(array $value) |
|
38 | + { |
|
39 | + $this->value = $value[1]; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -19,70 +19,70 @@ |
||
19 | 19 | |
20 | 20 | abstract class AbstractValue |
21 | 21 | { |
22 | - /** @var Compiler */ |
|
23 | - protected $compiler; |
|
24 | - /** @var Coerce */ |
|
25 | - protected $coerce; |
|
22 | + /** @var Compiler */ |
|
23 | + protected $compiler; |
|
24 | + /** @var Coerce */ |
|
25 | + protected $coerce; |
|
26 | 26 | |
27 | - protected $options = [ |
|
28 | - 'numberPrecision' => null, |
|
29 | - 'compressColors' => false, |
|
30 | - ]; |
|
27 | + protected $options = [ |
|
28 | + 'numberPrecision' => null, |
|
29 | + 'compressColors' => false, |
|
30 | + ]; |
|
31 | 31 | |
32 | - /** |
|
33 | - * AbstractValue constructor. |
|
34 | - * |
|
35 | - * @param Compiler $compiler |
|
36 | - * @param Coerce $coerce |
|
37 | - * @param array $options |
|
38 | - */ |
|
39 | - public function __construct(Compiler $compiler, Coerce $coerce, array $options = []) |
|
40 | - { |
|
41 | - $this->compiler = $compiler; |
|
42 | - $this->coerce = $coerce; |
|
43 | - $this->options = array_replace($this->options, $options); |
|
44 | - } |
|
32 | + /** |
|
33 | + * AbstractValue constructor. |
|
34 | + * |
|
35 | + * @param Compiler $compiler |
|
36 | + * @param Coerce $coerce |
|
37 | + * @param array $options |
|
38 | + */ |
|
39 | + public function __construct(Compiler $compiler, Coerce $coerce, array $options = []) |
|
40 | + { |
|
41 | + $this->compiler = $compiler; |
|
42 | + $this->coerce = $coerce; |
|
43 | + $this->options = array_replace($this->options, $options); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param Compiler $compiler |
|
48 | - * @param Coerce $coerce |
|
49 | - * @param array $options |
|
50 | - * @param array $value |
|
51 | - * |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
|
55 | - { |
|
56 | - $nameParts = explode('_', $value[0]); |
|
57 | - $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
58 | - return $carry.ucfirst($item); |
|
59 | - }, ''); |
|
60 | - $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
46 | + /** |
|
47 | + * @param Compiler $compiler |
|
48 | + * @param Coerce $coerce |
|
49 | + * @param array $options |
|
50 | + * @param array $value |
|
51 | + * |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
|
55 | + { |
|
56 | + $nameParts = explode('_', $value[0]); |
|
57 | + $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
58 | + return $carry.ucfirst($item); |
|
59 | + }, ''); |
|
60 | + $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
61 | 61 | |
62 | - if (class_exists($valueClassName)) { |
|
63 | - $valueClass = new $valueClassName($compiler, $coerce, $options); |
|
64 | - if ($valueClass instanceof self) { |
|
65 | - $valueClass->initializeFromOldFormat($value); |
|
62 | + if (class_exists($valueClassName)) { |
|
63 | + $valueClass = new $valueClassName($compiler, $coerce, $options); |
|
64 | + if ($valueClass instanceof self) { |
|
65 | + $valueClass->initializeFromOldFormat($value); |
|
66 | 66 | |
67 | - return $valueClass; |
|
68 | - } |
|
69 | - } |
|
67 | + return $valueClass; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
72 | - } |
|
71 | + throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - abstract public function getCompiled(); |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + abstract public function getCompiled(); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Initialize value from old array format. |
|
81 | - * |
|
82 | - * @param array $value |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @deprecated |
|
86 | - */ |
|
87 | - abstract public function initializeFromOldFormat(array $value); |
|
79 | + /** |
|
80 | + * Initialize value from old array format. |
|
81 | + * |
|
82 | + * @param array $value |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @deprecated |
|
86 | + */ |
|
87 | + abstract public function initializeFromOldFormat(array $value); |
|
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public static function factory(Compiler $compiler, Coerce $coerce, array $options, array $value) |
55 | 55 | { |
56 | 56 | $nameParts = explode('_', $value[0]); |
57 | - $camelCase = array_reduce($nameParts, function($carry, $item){ |
|
58 | - return $carry.ucfirst($item); |
|
57 | + $camelCase = array_reduce($nameParts, function($carry, $item) { |
|
58 | + return $carry . ucfirst($item); |
|
59 | 59 | }, ''); |
60 | - $valueClassName = 'LesserPhp\Compiler\Value\\'.$camelCase.'Value'; |
|
60 | + $valueClassName = 'LesserPhp\Compiler\Value\\' . $camelCase . 'Value'; |
|
61 | 61 | |
62 | 62 | if (class_exists($valueClassName)) { |
63 | 63 | $valueClass = new $valueClassName($compiler, $coerce, $options); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - throw new \UnexpectedValueException('unknown value type: '.$value[0]); |
|
71 | + throw new \UnexpectedValueException('unknown value type: ' . $value[0]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -17,33 +17,33 @@ |
||
17 | 17 | |
18 | 18 | class ListValue extends AbstractValue |
19 | 19 | { |
20 | - private $delimiter; |
|
21 | - /** @var AbstractValue[] */ |
|
22 | - private $items; |
|
20 | + private $delimiter; |
|
21 | + /** @var AbstractValue[] */ |
|
22 | + private $items; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @inheritdoc |
|
26 | - */ |
|
27 | - public function getCompiled() |
|
28 | - { |
|
29 | - $compiled = []; |
|
30 | - foreach ($this->items as $item) { |
|
31 | - $compiled[] = $item->getCompiled(); |
|
32 | - } |
|
24 | + /** |
|
25 | + * @inheritdoc |
|
26 | + */ |
|
27 | + public function getCompiled() |
|
28 | + { |
|
29 | + $compiled = []; |
|
30 | + foreach ($this->items as $item) { |
|
31 | + $compiled[] = $item->getCompiled(); |
|
32 | + } |
|
33 | 33 | |
34 | - return implode($this->delimiter, $compiled); |
|
35 | - } |
|
34 | + return implode($this->delimiter, $compiled); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @inheritdoc |
|
39 | - */ |
|
40 | - public function initializeFromOldFormat(array $value) |
|
41 | - { |
|
42 | - $this->delimiter = $value[1]; |
|
43 | - $this->items = []; |
|
37 | + /** |
|
38 | + * @inheritdoc |
|
39 | + */ |
|
40 | + public function initializeFromOldFormat(array $value) |
|
41 | + { |
|
42 | + $this->delimiter = $value[1]; |
|
43 | + $this->items = []; |
|
44 | 44 | |
45 | - foreach ($value[2] as $item) { |
|
46 | - $this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item); |
|
47 | - } |
|
48 | - } |
|
45 | + foreach ($value[2] as $item) { |
|
46 | + $this->items[] = self::factory($this->compiler, $this->coerce, $this->options, $item); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -17,44 +17,44 @@ |
||
17 | 17 | |
18 | 18 | class ColorValue extends AbstractValue |
19 | 19 | { |
20 | - private $red, $green, $blue, $alpha; |
|
21 | - |
|
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - $red = round($this->red); |
|
28 | - $green = round($this->green); |
|
29 | - $blue = round($this->blue); |
|
30 | - |
|
31 | - if ($this->alpha !== null && $this->alpha != 1) { |
|
32 | - return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
33 | - } |
|
34 | - |
|
35 | - $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
36 | - |
|
37 | - if ($this->options['compressColors']) { |
|
38 | - // Converting hex color to short notation (e.g. #003399 to #039) |
|
39 | - if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
40 | - $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - return $hex; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @inheritdoc |
|
49 | - */ |
|
50 | - public function initializeFromOldFormat(array $value) |
|
51 | - { |
|
52 | - $this->red = $value[1]; |
|
53 | - $this->green = $value[2]; |
|
54 | - $this->blue = $value[3]; |
|
55 | - |
|
56 | - if (isset($value[4])) { |
|
57 | - $this->alpha = $value[4]; |
|
58 | - } |
|
59 | - } |
|
20 | + private $red, $green, $blue, $alpha; |
|
21 | + |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + $red = round($this->red); |
|
28 | + $green = round($this->green); |
|
29 | + $blue = round($this->blue); |
|
30 | + |
|
31 | + if ($this->alpha !== null && $this->alpha != 1) { |
|
32 | + return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
33 | + } |
|
34 | + |
|
35 | + $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
36 | + |
|
37 | + if ($this->options['compressColors']) { |
|
38 | + // Converting hex color to short notation (e.g. #003399 to #039) |
|
39 | + if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
40 | + $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + return $hex; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * @inheritdoc |
|
49 | + */ |
|
50 | + public function initializeFromOldFormat(array $value) |
|
51 | + { |
|
52 | + $this->red = $value[1]; |
|
53 | + $this->green = $value[2]; |
|
54 | + $this->blue = $value[3]; |
|
55 | + |
|
56 | + if (isset($value[4])) { |
|
57 | + $this->alpha = $value[4]; |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $blue = round($this->blue); |
30 | 30 | |
31 | 31 | if ($this->alpha !== null && $this->alpha != 1) { |
32 | - return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
32 | + return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $this->alpha . ')'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if ($this->options['compressColors']) { |
38 | 38 | // Converting hex color to short notation (e.g. #003399 to #039) |
39 | 39 | if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
40 | - $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
40 | + $hex = '#' . $hex[1] . $hex[3] . $hex[5]; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 |
@@ -17,27 +17,27 @@ |
||
17 | 17 | |
18 | 18 | class NumberValue extends AbstractValue |
19 | 19 | { |
20 | - private $number, $unit; |
|
20 | + private $number, $unit; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - $num = $this->number; |
|
28 | - if (isset($this->options['numberPrecision'])) { |
|
29 | - $num = round($num, $this->options['numberPrecision']); |
|
30 | - } |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + $num = $this->number; |
|
28 | + if (isset($this->options['numberPrecision'])) { |
|
29 | + $num = round($num, $this->options['numberPrecision']); |
|
30 | + } |
|
31 | 31 | |
32 | - return $num.$this->unit; |
|
33 | - } |
|
32 | + return $num.$this->unit; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @inheritdoc |
|
37 | - */ |
|
38 | - public function initializeFromOldFormat(array $value) |
|
39 | - { |
|
40 | - $this->number = $value[1]; |
|
41 | - $this->unit = $value[2]; |
|
42 | - } |
|
35 | + /** |
|
36 | + * @inheritdoc |
|
37 | + */ |
|
38 | + public function initializeFromOldFormat(array $value) |
|
39 | + { |
|
40 | + $this->number = $value[1]; |
|
41 | + $this->unit = $value[2]; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $num = round($num, $this->options['numberPrecision']); |
30 | 30 | } |
31 | 31 | |
32 | - return $num.$this->unit; |
|
32 | + return $num . $this->unit; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -17,22 +17,22 @@ |
||
17 | 17 | |
18 | 18 | class FunctionValue extends AbstractValue |
19 | 19 | { |
20 | - private $name, $args; |
|
20 | + private $name, $args; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - return $this->name.'('.$this->compiler->compileValue($this->args).')'; |
|
28 | - } |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + return $this->name.'('.$this->compiler->compileValue($this->args).')'; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @inheritdoc |
|
32 | - */ |
|
33 | - public function initializeFromOldFormat(array $value) |
|
34 | - { |
|
35 | - $this->name = $value[1]; |
|
36 | - $this->args = $value[2]; |
|
37 | - } |
|
30 | + /** |
|
31 | + * @inheritdoc |
|
32 | + */ |
|
33 | + public function initializeFromOldFormat(array $value) |
|
34 | + { |
|
35 | + $this->name = $value[1]; |
|
36 | + $this->args = $value[2]; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function getCompiled() |
26 | 26 | { |
27 | - return $this->name.'('.$this->compiler->compileValue($this->args).')'; |
|
27 | + return $this->name . '(' . $this->compiler->compileValue($this->args) . ')'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -17,29 +17,29 @@ |
||
17 | 17 | |
18 | 18 | class StringValue extends AbstractValue |
19 | 19 | { |
20 | - private $delimiter, $content; |
|
20 | + private $delimiter, $content; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritdoc |
|
24 | - */ |
|
25 | - public function getCompiled() |
|
26 | - { |
|
27 | - $content = $this->content; |
|
28 | - foreach ($content as &$part) { |
|
29 | - if (is_array($part)) { |
|
30 | - $part = $this->compiler->compileValue($part); |
|
31 | - } |
|
32 | - } |
|
22 | + /** |
|
23 | + * @inheritdoc |
|
24 | + */ |
|
25 | + public function getCompiled() |
|
26 | + { |
|
27 | + $content = $this->content; |
|
28 | + foreach ($content as &$part) { |
|
29 | + if (is_array($part)) { |
|
30 | + $part = $this->compiler->compileValue($part); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - return $this->delimiter . implode($content) . $this->delimiter; |
|
35 | - } |
|
34 | + return $this->delimiter . implode($content) . $this->delimiter; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @inheritdoc |
|
39 | - */ |
|
40 | - public function initializeFromOldFormat(array $value) |
|
41 | - { |
|
42 | - $this->delimiter=$value[1]; |
|
43 | - $this->content=$value[2]; |
|
44 | - } |
|
37 | + /** |
|
38 | + * @inheritdoc |
|
39 | + */ |
|
40 | + public function initializeFromOldFormat(array $value) |
|
41 | + { |
|
42 | + $this->delimiter=$value[1]; |
|
43 | + $this->content=$value[2]; |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function initializeFromOldFormat(array $value) |
41 | 41 | { |
42 | - $this->delimiter=$value[1]; |
|
43 | - $this->content=$value[2]; |
|
42 | + $this->delimiter = $value[1]; |
|
43 | + $this->content = $value[2]; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -1111,42 +1111,42 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | |
1114 | - /** |
|
1115 | - * Compiles a primitive value into a CSS property value. |
|
1116 | - * |
|
1117 | - * Values in lessphp are typed by being wrapped in arrays, their format is |
|
1118 | - * typically: |
|
1119 | - * |
|
1120 | - * array(type, contents [, additional_contents]*) |
|
1121 | - * |
|
1122 | - * The input is expected to be reduced. This function will not work on |
|
1123 | - * things like expressions and variables. |
|
1124 | - * |
|
1125 | - * @param array $value |
|
1126 | - * @param array $options |
|
1127 | - * |
|
1128 | - * @return string |
|
1129 | - * @throws GeneralException |
|
1130 | - */ |
|
1131 | - public function compileValue(array $value, array $options = []) |
|
1132 | - { |
|
1133 | - try { |
|
1134 | - if (!isset($value[0])) { |
|
1135 | - throw new GeneralException('Missing value type'); |
|
1136 | - } |
|
1137 | - |
|
1138 | - $options = array_replace([ |
|
1139 | - 'numberPrecision' => $this->numberPrecision, |
|
1140 | - 'compressColors' => ($this->formatter ? $this->formatter->getCompressColors() : false), |
|
1141 | - ], $options); |
|
1142 | - |
|
1143 | - $valueClass = \LesserPhp\Compiler\Value\AbstractValue::factory($this, $this->coerce, $options, $value); |
|
1144 | - |
|
1145 | - return $valueClass->getCompiled(); |
|
1146 | - } catch (\UnexpectedValueException $e) { |
|
1147 | - throw new GeneralException($e->getMessage()); |
|
1148 | - } |
|
1149 | - } |
|
1114 | + /** |
|
1115 | + * Compiles a primitive value into a CSS property value. |
|
1116 | + * |
|
1117 | + * Values in lessphp are typed by being wrapped in arrays, their format is |
|
1118 | + * typically: |
|
1119 | + * |
|
1120 | + * array(type, contents [, additional_contents]*) |
|
1121 | + * |
|
1122 | + * The input is expected to be reduced. This function will not work on |
|
1123 | + * things like expressions and variables. |
|
1124 | + * |
|
1125 | + * @param array $value |
|
1126 | + * @param array $options |
|
1127 | + * |
|
1128 | + * @return string |
|
1129 | + * @throws GeneralException |
|
1130 | + */ |
|
1131 | + public function compileValue(array $value, array $options = []) |
|
1132 | + { |
|
1133 | + try { |
|
1134 | + if (!isset($value[0])) { |
|
1135 | + throw new GeneralException('Missing value type'); |
|
1136 | + } |
|
1137 | + |
|
1138 | + $options = array_replace([ |
|
1139 | + 'numberPrecision' => $this->numberPrecision, |
|
1140 | + 'compressColors' => ($this->formatter ? $this->formatter->getCompressColors() : false), |
|
1141 | + ], $options); |
|
1142 | + |
|
1143 | + $valueClass = \LesserPhp\Compiler\Value\AbstractValue::factory($this, $this->coerce, $options, $value); |
|
1144 | + |
|
1145 | + return $valueClass->getCompiled(); |
|
1146 | + } catch (\UnexpectedValueException $e) { |
|
1147 | + throw new GeneralException($e->getMessage()); |
|
1148 | + } |
|
1149 | + } |
|
1150 | 1150 | |
1151 | 1151 | /** |
1152 | 1152 | * Helper function to get arguments for color manipulation functions. |
@@ -2055,9 +2055,9 @@ discard block |
||
2055 | 2055 | $this->formatterName = $name; |
2056 | 2056 | } |
2057 | 2057 | |
2058 | - public function setFormatterClass($formatter) |
|
2059 | - { |
|
2060 | - $this->formatter = $formatter; |
|
2058 | + public function setFormatterClass($formatter) |
|
2059 | + { |
|
2060 | + $this->formatter = $formatter; |
|
2061 | 2061 | } |
2062 | 2062 | |
2063 | 2063 | /** |