public function SassNumber::coerce in Sassy 7
Same name and namespace in other branches
- 7.3 phpsass/script/literals/SassNumber.php \SassNumber::coerce()
* Returns the value of this number converted to other units. * The conversion takes into account the relationship between e.g. mm and cm, * as well as between e.g. in and cm. * * If this number is unitless, it will simply return itself with the given units. *
Parameters
array $numeratorUnits: * @param array $denominatorUnits * @return SassNumber
File
- phamlp/
sass/ script/ literals/ SassNumber.php, line 313
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 coerce($numeratorUnits, $denominatorUnits) {
return new SassNumber(($this
->isUnitless() ? $this->value : $this->value * $this
->coercionFactor($this->numeratorUnits, $numeratorUnits) / $this
->coercionFactor($this->denominatorUnits, $denominatorUnits)) . join(' * ', $numeratorUnits) . (!empty($denominatorUnits) ? ' / ' . join(' * ', $denominatorUnits) : ''));
}