public static function SassScriptFunctions::percentage in Sassy 7
Same name and namespace in other branches
- 7.3 phpsass/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 new SassNumber The number as a percentage * @throws SassScriptFunctionException If $number isn't a unitless number
File
- phamlp/sass/ script/ SassScriptFunctions.php, line 640 
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('{what} must be a {type}', array(
      '{what}' => 'number',
      '{type}' => 'unitless SassNumber',
    ), SassScriptParser::$context->node);
  }
  $number->value *= 100;
  $number->units = '%';
  return $number;
}