Conditions | 7 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
28 | 13 | public function getCompiled() |
|
29 | { |
||
30 | 13 | $red = round($this->red); |
|
31 | 13 | $green = round($this->green); |
|
32 | 13 | $blue = round($this->blue); |
|
33 | |||
34 | 13 | if ($this->alpha !== null && $this->alpha != 1) { |
|
35 | 4 | return 'rgba('.$red.','.$green.','.$blue.','.$this->alpha.')'; |
|
36 | } |
||
37 | |||
38 | 12 | $hex = sprintf("#%02x%02x%02x", $red, $green, $blue); |
|
39 | |||
40 | 12 | if ($this->options['compressColors']) { |
|
41 | // Converting hex color to short notation (e.g. #003399 to #039) |
||
42 | 3 | if ($hex[1] === $hex[2] && $hex[3] === $hex[4] && $hex[5] === $hex[6]) { |
|
43 | 3 | $hex = '#'.$hex[1].$hex[3].$hex[5]; |
|
44 | } |
||
45 | } |
||
46 | |||
47 | 12 | return $hex; |
|
48 | } |
||
49 | |||
63 | } |