ajout de stats sur le budget des villes
This commit is contained in:
parent
1973f85dd4
commit
cd8369d08c
14 changed files with 901 additions and 186 deletions
55
src/Command/TestBudgetCommand.php
Normal file
55
src/Command/TestBudgetCommand.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use App\Service\BudgetService;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'app:test-budget',
|
||||
description: 'Test du service BudgetService',
|
||||
)]
|
||||
class TestBudgetCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private BudgetService $budgetService
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
// Test avec un code INSEE
|
||||
$codeInsee = '37261'; // Tours
|
||||
$io->info("Test du budget pour le code INSEE: $codeInsee");
|
||||
|
||||
try {
|
||||
$budget = $this->budgetService->getBudgetAnnuel($codeInsee);
|
||||
if ($budget !== null) {
|
||||
$io->success("Budget annuel récupéré: " . number_format($budget, 2) . " €");
|
||||
|
||||
// Test avec une population fictive
|
||||
$population = 138668; // Population de Tours
|
||||
$budgetParHabitant = $this->budgetService->getBudgetParHabitant($budget, $population);
|
||||
$io->info("Budget par habitant: " . number_format($budgetParHabitant, 2) . " €");
|
||||
|
||||
// Test écart à la moyenne
|
||||
$moyenne = 1500; // Moyenne fictive
|
||||
$ecart = $this->budgetService->getEcartMoyenneBudgetParHabitant($budgetParHabitant, $moyenne);
|
||||
$io->info("Écart à la moyenne: " . number_format($ecart, 2) . "%");
|
||||
} else {
|
||||
$io->warning("Aucun budget récupéré");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$io->error("Erreur: " . $e->getMessage());
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue