You are here

private function SassNumber::removeCommonUnits in Sassy 7

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

* Removes common units from each set. * We don't use array_diff because we want (for eaxmple) mm*mm/mm*cm to * end up as mm/cm. *

Parameters

array first set of units: * @param array second set of units * @return array both sets of units with common units removed

2 calls to SassNumber::removeCommonUnits()
SassNumber::coercionFactor in phamlp/sass/script/literals/SassNumber.php
* Calculates the corecion factor to apply to the value *
SassNumber::__construct in phamlp/sass/script/literals/SassNumber.php
* class constructor. * Sets the value and units of the number. *

File

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

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 removeCommonUnits($u1, $u2) {
  $_u1 = array();
  while (!empty($u1)) {
    $u = array_shift($u1);
    $i = array_search($u, $u2);
    if ($i !== false) {
      unset($u2[$i]);
    }
    else {
      $_u1[] = $u;
    }
  }
  return array(
    $_u1,
    $u2,
  );
}