public static function SassScriptFunctions::percentage in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/script/SassScriptFunctions.php \SassScriptFunctions::percentage()
Converts a decimal number to a percentage. For example: percentage(100px / 50px) => 200%
Parameters
SassNumber The decimal number to convert to a percentage:
Return value
new SassNumber The number as a percentage
Throws
SassScriptFunctionException If $number isn't a unitless number
File
- phpsass/
script/ SassScriptFunctions.php, line 647
Class
- SassScriptFunctions
- SassScript functions class. A collection of functions for use in SassSCript. @package PHamlP @subpackage Sass.script
Code
public static function percentage($number) {
if (!$number instanceof SassNumber || $number
->hasUnits()) {
throw new SassScriptFunctionException('number must be a unitless SassNumber', SassScriptParser::$context->node);
}
$number->value *= 100;
$number->units = '%';
return $number;
}