public function UnitsEntity::inverseDecompose in Units of Measurement 7.2
Create inverse decomposition mathematical expression.
Return value
UnitsMathematicalExpression Inverse decomposition mathematical expression
File
- includes/
UnitsEntity.class.inc, line 99 - Definition of UnitsEntity class.
Class
- UnitsEntity
- Units of measurement entity class.
Code
public function inverseDecompose() {
$decomposition = $this
->decompose();
if (!$this
->isLinear()) {
$straight_decomposition = $decomposition;
$decomposition = new UnitsConstantMathematicalExpression(UNITS_QUANTITY);
while (get_class($straight_decomposition) == 'UnitsMathematicalOperatorLinear') {
$operand1 = $straight_decomposition
->operand1();
$operand2 = $straight_decomposition
->operand2();
$operand_to_isolate = strpos($operand1
->toPostfix(), UNITS_QUANTITY) !== FALSE ? 1 : 2;
$decomposition = $straight_decomposition
->isolateOperand($decomposition, $operand_to_isolate);
$straight_decomposition = $operand_to_isolate == 1 ? $operand1 : $operand2;
}
}
return $decomposition;
}