/** * Calculates new rankings and returns in RatingsOutput * @return RatingsOutput represents new rankings */ public function calculate() { if ($this->ratingsInput->isNeutralVenue()) { $calculate = new CalculateNeutralVenue($this->ratingsInput); return $calculate->getOutput(); } $calculate = new Calculate($this->ratingsInput); return $calculate->getOutput(); }
<?php if ($_POST) { include 'calculate.php'; $notas = $_POST['nota']; $promedios = $_POST['prom']; $total_prom = Calculate::totalProm($promedios); header('Content-type: application/json; charset=utf-8'); /*Validar que no sea superior al 100% del porcentaje*/ if ($total_prom > 100) { $response = ['class' => 'error', 'message' => 'Acaba de superar el 100%']; } else { $nota = Calculate::notaActual($notas, $promedios); if ($total_prom == 100) { /*Calcular 100% de la matería*/ $response = ['class' => 'success', 'message' => 'Nota definitiva(100%): ' . $nota]; } else { /*Calcular el promedio cuando no es igual a 100%*/ $necesaria = Calculate::notaNecesaria($nota, $total_prom); $necesaria = round($necesaria, 2); $prom_not_eval = 100 - $total_prom; if ($necesaria < 0) { $necesaria = 0; } $response = ['class' => 'partial', 'message' => 'Nota parcial(' . $total_prom . '%): ' . $nota . ', Nota necesaria(' . $prom_not_eval . '%): ' . $necesaria]; } } echo json_encode($response, JSON_FORCE_OBJECT); }
/** * @test */ public function method_call_twice() { $mockClass = new PHPUnit_Extensions_MockClass('Calculate', ['debug'], $this); $mockClass->expects($this->exactly(2))->method('debug'); $Calculate = new Calculate(4, 2); $Calculate->debug(); $Calculate->debug(); }
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>price</title> </head> <body> <?php require_once 'Calculate.php'; $price = new Calculate(0.08); print "税込み金額は {$price->taxCalculate(1000)}円です"; ?> </body> </html>