public function SassNumber::toString in Sassy 7
Same name and namespace in other branches
- 7.3 phpsass/script/literals/SassNumber.php \SassNumber::toString()
* Converts the number to a string with it's units if any. * If the units are px the result is rounded down to the nearest integer, * otherwise the result is rounded to the specified precision. *
Return value
string number as a string with it's units if any
Overrides SassLiteral::toString
File
- phamlp/
sass/ script/ literals/ SassNumber.php, line 498
Class
- SassNumber
- SassNumber class. Provides operations and type testing for Sass numbers. Units are of the passed value are converted the those of the class value if it has units. e.g. 2cm + 20mm = 4cm while 2 + 20mm =…
Code
public function toString() {
if (!$this
->hasLegalUnits()) {
throw new SassNumberException('Invalid {what}', array(
'{what}' => "CSS units ({$this->units})",
), SassScriptParser::$context->node);
}
return ($this->units == 'px' ? floor($this->value) : round($this->value, self::PRECISION)) . $this->units;
}