Same name and namespace in other branches
  1. 8.x-2.x src/ColorRGB.php \Drupal\color_field\ColorRGB::toString() 1 comment

A string representation of this color in the current format.

Parameters

bool $opacity: Whether to display the opacity.

Return value

string The color in format: #RRGGBB

Overrides ColorInterface::toString

File

src/ColorRGB.php, line 91

Class

ColorRGB
RGB represents the RGB color format.

Namespace

Drupal\color_field

Code

public function toString(bool $opacity = TRUE) : string {
    $output = $opacity ? 'rgba(' . $this->getRed() . ',' . $this->getGreen() . ',' . $this->getBlue() . ',' . $this->getOpacity() . ')' : 'rgb(' . $this->getRed() . ',' . $this->getGreen() . ',' . $this->getBlue() . ')';
    return strtolower($output);
}