You are here

public function SassColour::op_times in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassColour.php \SassColour::op_times()

* Colour multiplication *

Parameters

mixed SassColour|SassNumber value to multiply by: * @return sassColour the colour result

Overrides SassLiteral::op_times

File

phamlp/sass/script/literals/SassColour.php, line 400

Class

SassColour
SassColour class. A SassScript object representing a CSS colour.

Code

public function op_times($other) {
  if ($other instanceof SassNumber) {
    if (!$other
      ->isUnitless()) {
      throw new SassColourException('{what} must be a {type}', array(
        '{what}' => Phamlp::t('sass', 'Number'),
        '{type}' => Phamlp::t('sass', 'unitless number'),
      ), SassScriptParser::$context->node);
    }
    $this->red = $this
      ->getRed() * $other->value;
    $this->green = $this
      ->getGreen() * $other->value;
    $this->blue = $this
      ->getBlue() * $other->value;
  }
  elseif (!$other instanceof SassColour) {
    throw new SassColourException('{what} must be a {type}', array(
      '{what}' => 'Argument',
      '{type}' => 'SassColour or SassNumber',
    ), SassScriptParser::$context->node);
  }
  else {
    $this->red = $this
      ->getRed() * $other
      ->getRed();
    $this->green = $this
      ->getGreen() * $other
      ->getGreen();
    $this->blue = $this
      ->getBlue() * $other
      ->getBlue();
  }
  return $this;
}