public function calculate( ) { $this->initializeCalculator( ); if( ! empty($_POST['hasSubmit']) ) { $leftOperand = (isset($_POST['leftOperand']) ? (int)$_POST['leftOperand'] : null ); $rightOperand = (isset($_POST['rightOperand']) ? (int)$_POST['rightOperand'] : null ); $firstOperator = (isset($_POST['firstOperator']) ? $_POST['firstOperator'] : null ); $secondOperator = (isset($_POST['secondOperator']) ? $_POST['secondOperator'] : null ); if( $secondOperator != '=' ) { $this->registry->template->firstOperator = $secondOperator; } $calculator = new Math( ); $calculator->setFirstOperand($leftOperand); $calculator->setSecondOperand($rightOperand); $calculator->setFirstOperator($firstOperator); $calculator->setSecondOperator($secondOperator); $this->registry->template->leftOperand = $calculator->calculate(); } $this->registry->template->show('math_index'); }