public function SassScriptOperation::perform in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/script/SassScriptOperation.php \SassScriptOperation::perform()
Performs this operation.
Parameters
array operands for the operation. The operands are SassLiterals:
Return value
SassLiteral the result of the operation
Throws
SassScriptOperationException if the oprand count is incorrect or the operation is undefined
File
- phpsass/
script/ SassScriptOperation.php, line 120
Class
- SassScriptOperation
- SassScriptOperation class. The operation to perform. @package PHamlP @subpackage Sass.script
Code
public function perform($operands) {
if (count($operands) !== $this->operandCount) {
throw new SassScriptOperationException('Incorrect operand count for ' . get_class($operands[0]) . '; expected ' . $this->operandCount . ', received ' . count($operands), SassScriptParser::$context->node);
}
if (count($operands) > 1 && is_null($operands[1])) {
$operation = 'op_unary_' . $this->operator;
}
else {
$operation = 'op_' . $this->operator;
if ($this->associativity == 'l') {
$operands = array_reverse($operands);
}
}
if (method_exists($operands[0], $operation)) {
$op = clone $operands[0];
return $op
->{$operation}(!empty($operands[1]) ? $operands[1] : null);
}
throw new SassScriptOperationException('Undefined operation "' . $operation . '" for ' . get_class($operands[0]), SassScriptParser::$context->node);
}