You are here

public function Color::getRed in Color API 8

Retrieve 'Red' value of the Color Field Color data object RGB property.

Return value

array The value for the RGB "red". An integer between 0 and 255.

Overrides ColorInterface::getRed

File

src/Entity/Color.php, line 87

Class

Color
The Color API Color entity definition.

Namespace

Drupal\colorapi\Entity

Code

public function getRed() {
  if ($color = $this
    ->get('color')) {
    return \Drupal::service('colorapi.service')
      ->hexToRgb($color, 'red');
  }
}