/** * Divides this value by the value of other * * @param * mixed SassNumber|SassColour: value to divide by * @return mixed SassNumber if other is a SassNumber or * SassColour if it is a SassColour */ public function op_div($other) { if ($other instanceof SassColour) { return $other->op_div($this); } elseif (!$other instanceof SassNumber) { throw new SassNumberException('{what} must be a {type}', array('{what}' => Phamlp::t('sass', 'Number'), '{type}' => Phamlp::t('sass', 'number')), SassScriptParser::$context->node); } elseif ($this->inExpression || $other->inExpression) { return new SassNumber($this->value / $other->value . $this->unitString(array_merge($this->numeratorUnits, $other->denominatorUnits), array_merge($this->denominatorUnits, $other->numeratorUnits))); } else { return parent::op_div($other); } }
/** * SassScript '/' operation. * @param SassLiteral $other value to divide by * @return sassString the string values of this and other seperated by '/' */ public function op_div($other) { return new SassString($this->toString() . ' / ' . $other->toString()); }
/** * Inspects the type of the argument, returning it as an unquoted string. * @param SassLiteral The object to inspect * @return new SassString The type of object * @throws SassScriptFunctionException If $obj is not an instance of a * SassLiteral */ public static function type_of($obj) { SassLiteral::assertType($obj, SassLiteral); return new SassString($obj->typeOf); }
public static function grad_position($colourList, $index, $default, $radial = null) { SassLiteral::assertType($colourList, 'CompassList'); if (is_null($radial)) { $radial = new SassBoolean(false); } else { SassLiteral::assertType($radial, 'SassBoolean'); } $stop = $colourList->values[$index->value - 1]->stop; if ($stop && $radial->value) { $orig_stop = $stop; if ($stop->isUnitless()) { if ($stop->value <= 1) { # A unitless number is assumed to be a percentage when it's between 0 and 1 $stop = $stop->op_times(new SassNumber('100%')); } else { # Otherwise, a unitless number is assumed to be in pixels $stop = $stop->op_times(new SassNumber('1px')); } } if ($stop->numeratorUnits === '%' && isset($colourList->values[sizeof($colourList->values) - 1]->stop) && $colourList->values[sizeof($colourList->values) - 1]->stop->numeratorUnits === 'px') { $stop = $stop->op_times($colourList->values[sizeof($colourList->values) - 1]->stop)->op_div(new SassNumber('100%')); } //Compass::Logger.new.record(:warning, "Webkit only supports pixels for the start and end stops for radial gradients. Got: #{orig_stop}") if stop.numerator_units != ["px"]; return $stop->op_div(new SassNumber('1' . $stop->units)); } elseif ($stop) { return $stop; } else { return $default; } }