You are here

private function SassNumber::convert in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassNumber.php \SassNumber::convert()

* Converts values and units. * If this is a unitless numeber it will take the units of other; if not * other is coerced to the units of this. *

Parameters

SassNumber the other number: * @return SassNumber the other number with its value and units coerced if neccessary * @throws SassNumberException if the units are incompatible

2 calls to SassNumber::convert()
SassNumber::op_minus in phamlp/sass/script/literals/SassNumber.php
* Subtracts the value of other from this value *
SassNumber::op_plus in phamlp/sass/script/literals/SassNumber.php
* Adds the value of other to the value of this *

File

phamlp/sass/script/literals/SassNumber.php, line 292

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

private function convert($other) {
  if ($this
    ->isUnitless()) {
    $this->numeratorUnits = $other->numeratorUnits;
    $this->denominatorUnits = $other->denominatorUnits;
  }
  else {
    $other = $other
      ->coerce($this->numeratorUnits, $this->denominatorUnits);
  }
  return $other;
}