Conditions | 7 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
43 | 13 | public function getCompiled() |
|
44 | { |
||
45 | 13 | $red = round($this->red); |
|
46 | 13 | $green = round($this->green); |
|
47 | 13 | $blue = round($this->blue); |
|
48 | |||
49 | 13 | if ($this->alpha !== null && $this->alpha != 1) { |
|
50 | 4 | return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $this->alpha . ')'; |
|
51 | } |
||
52 | |||
53 | 12 | $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
54 | |||
55 | 12 | if ($this->options['compressColors']) { |
|
56 | // Converting hex color to short notation (e.g. #003399 to #039) |
||
57 | 3 | if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
58 | 3 | $hex = '#' . $hex[1] . $hex[3] . $hex[5]; |
|
59 | } |
||
60 | } |
||
61 | |||
62 | 12 | return $hex; |
|
63 | } |
||
64 | |||
79 |