diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php
index 87b570a..f455e90 100644
--- a/src/Controller/HomeController.php
+++ b/src/Controller/HomeController.php
@@ -3,7 +3,6 @@
namespace App\Controller;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
-use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Request;
@@ -41,7 +40,7 @@ class HomeController extends AbstractController
return $clientRegistry
->getClient('openstreetmap') // cf `config/packages/knpu_oauth2_client.yaml`
->redirect([
- 'read_prefs', // TODO est-ce qu’on a même besoin de ça ?
+ 'read_prefs', // TODO est-ce qu’on a même besoin de ça ?
]);
}
@@ -69,6 +68,4 @@ class HomeController extends AbstractController
{
return $security->logout();
}
-
-
}
diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php
index 38da4a4..af38bf3 100644
--- a/src/Controller/ProjectController.php
+++ b/src/Controller/ProjectController.php
@@ -18,7 +18,6 @@ use Symfony\Component\Routing\Attribute\Route;
#[Route('/project')]
class ProjectController extends AbstractController
{
-
// Page des projets, où l'on voit tous les projets
#[Route('/', name: 'app_project')]
public function index(EntityManagerInterface $entityManager): Response
@@ -77,7 +76,7 @@ class ProjectController extends AbstractController
$randomTask = $entityManager->getRepository(Task::class)->findRandomByProject($project, Task::STATUS_TODO); // Trouve la tâche à faire que l’on piochera
$csvForm = $this->createForm(CsvType::class, null, [
- 'action' => $this->generateUrl('app_project_import', ['slug' => $slug])
+ 'action' => $this->generateUrl('app_project_import', ['slug' => $slug]),
]);
$csvForm->add('submit', SubmitType::class, ['label' => 'Importer']);
@@ -178,7 +177,7 @@ class ProjectController extends AbstractController
]);
}
- // La suppression d’un projet passe par là
+ // La suppression d’un projet passe par là
#[Route('/{slug}/remove', name: 'app_project_remove')]
public function remove(EntityManagerInterface $entityManager, $slug): Response
{
@@ -212,20 +211,23 @@ class ProjectController extends AbstractController
if (!$project) {
$this->addFlash('warning', 'Projet non trouvé !');
+
return $this->redirectToRoute('app_project');
}
if (!$project->hasOverpassQuery()) {
$this->addFlash('warning', 'Ce projet n’a pas de requête Overpass !');
+
return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]);
}
if ($project->hasOverpassResult() and !$project->isOverpassResultOutdated()) {
$this->addFlash('warning', 'Merci d’attendre un peu avant de requêter de nouveau Overpass !');
+
return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]);
}
- $result = $overpassClient->query($project->getOverpassQuery());
+ $result = $overpassClient->query($project->getOverpassQuery());
$project->setOverpassResult($result);
@@ -234,5 +236,4 @@ class ProjectController extends AbstractController
return $this->redirectToRoute('app_project_show', ['slug' => $project->getSlug()]);
}
-
}
diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php
index 953a492..857dbfb 100644
--- a/src/Controller/TaskController.php
+++ b/src/Controller/TaskController.php
@@ -8,7 +8,6 @@ use App\Entity\Task;
use App\Form\CommentType;
use App\Form\TaskType;
use App\Service\GeoJsonManager;
-use App\Service\OpenStreetMapClient;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -24,12 +23,13 @@ use Symfony\Component\Workflow\WorkflowInterface;
#[Route('/task')]
class TaskController extends AbstractController
{
- // Page de créatiom d’une tâche
+ // Page de créatiom d’une tâche
#[Route('/create', name: 'app_task_create')]
public function create(Request $request, EntityManagerInterface $entityManager): Response
{
if (!$request->query->has('slug')) {
- $this->addFlash( 'warning', 'Projet non spécifié !');
+ $this->addFlash('warning', 'Projet non spécifié !');
+
return $this->redirectToRoute('app_project');
}
@@ -39,7 +39,8 @@ class TaskController extends AbstractController
$project = $repository->findOneBySlug($slug);
if (!$project) {
- $this->addFlash( 'warning', 'Projet non trouvé !');
+ $this->addFlash('warning', 'Projet non trouvé !');
+
return $this->redirectToRoute('app_project');
}
@@ -70,13 +71,12 @@ class TaskController extends AbstractController
}
}
-
return $this->render('task/create.html.twig', [
'project' => $project,
'create_form' => $createForm,
]);
}
-
+
// Page spécifique à une tâche, où l’on trouve tout ce qui la concerne
#[Route('/{slug}', name: 'app_task_show')]
public function show(Request $request, EntityManagerInterface $entityManager, GeoJsonManager $geoJsonManager, $slug): Response
@@ -90,6 +90,7 @@ class TaskController extends AbstractController
if (!$request->headers->has('Referer')) {
throw $this->createNotFoundException('Task not found');
}
+
return $this->redirect($request->headers->get('Referer'));
}
@@ -135,8 +136,8 @@ class TaskController extends AbstractController
'left' => $bbox['minx'],
'right' => $bbox['maxx'],
'changeset_comment' => sprintf('%s %s', $project->getName(), $task->getName()),
- 'changeset_source' => $project->getSource(),
- 'changeset_hashtags' => $project->getHashtags(),
+ 'changeset_source' => $project->getSource(),
+ 'changeset_hashtags' => $project->getHashtags(),
];
}
@@ -177,9 +178,8 @@ class TaskController extends AbstractController
try {
$entityManager->persist($comment);
$entityManager->flush();
-
} catch (\Exception $exception) {
- $this->addFlash('danger', 'Impossible de commenter ! ' . $exception->getMessage());
+ $this->addFlash('danger', 'Impossible de commenter ! '.$exception->getMessage());
}
}
@@ -234,13 +234,13 @@ class TaskController extends AbstractController
if (!$task) {
$this->addFlash('warning', 'Tâche non trouvée !');
+
return $this->redirect($request->headers->get('Referer'));
}
$project = $task->getProject();
try {
-
$entityManager->remove($task);
$entityManager->flush();
@@ -260,6 +260,7 @@ class TaskController extends AbstractController
if (!$task) {
$this->addFlash('warning', 'Tâche non trouvée !');
+
return $this->redirectToRoute('app_project');
}
@@ -317,6 +318,7 @@ class TaskController extends AbstractController
if (!$request->headers->has('Referer')) {
throw $this->createNotFoundException('Task not found');
}
+
return $this->redirect($request->headers->get('Referer'));
}
@@ -346,6 +348,7 @@ class TaskController extends AbstractController
if (!$request->headers->has('Referer')) {
throw $this->createNotFoundException('Task not found');
}
+
return $this->redirect($request->headers->get('Referer'));
}
@@ -383,6 +386,7 @@ class TaskController extends AbstractController
'warning',
'Tâche non trouvée !'
);
+
return $this->redirect($request->headers->get('referer'));
}
@@ -401,7 +405,7 @@ class TaskController extends AbstractController
return $response;
}
-
+
// Renvoie la liste des tâches du projet sous forme de CSV (ce qui devrait
// corresponddre à ce que l’on a pu importer)
#[Route('/download/{slug}.csv', name: 'app_task_csv')]
@@ -412,6 +416,7 @@ class TaskController extends AbstractController
if (!$project) {
$this->addFlash('warning', 'Projet non trouvé !');
+
return $this->redirect($request->headers->get('referer'));
}
@@ -428,9 +433,9 @@ class TaskController extends AbstractController
'status',
]
);
- foreach($project->getTasks() as $task) {
+ foreach ($project->getTasks() as $task) {
fputcsv(
- $output,
+ $output,
[
$task->getName(),
$task->getDescription(),
@@ -452,5 +457,4 @@ class TaskController extends AbstractController
return $response;
}
-
}
diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php
index 6da7dba..4aeeea0 100644
--- a/src/DataFixtures/AppFixtures.php
+++ b/src/DataFixtures/AppFixtures.php
@@ -2,9 +2,7 @@
namespace App\DataFixtures;
-use App\Entity\Project;
use App\Entity\Tag;
-use App\Entity\Task;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
diff --git a/src/Entity/Project.php b/src/Entity/Project.php
index b26dabd..892024f 100644
--- a/src/Entity/Project.php
+++ b/src/Entity/Project.php
@@ -271,11 +271,10 @@ class Project
$generatedAt = new \DateTimeImmutable($data['osm3s']['timestamp_osm_base']);
$now = new \DateTimeImmutable('now');
- $minimum = new \DateInterval('PT5M');
+ $minimum = new \DateInterval('PT5M');
$isOutdated = ($generatedAt->add($minimum) < $now);
return $isOutdated;
}
-
}
diff --git a/src/Entity/Task.php b/src/Entity/Task.php
index 1d8c7f8..c7f6508 100644
--- a/src/Entity/Task.php
+++ b/src/Entity/Task.php
@@ -14,14 +14,14 @@ use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: TaskRepository::class)]
class Task
{
- const STATUS_TODO = 'todo';
- const STATUS_DOING = 'doing';
- const STATUS_DONE = 'done';
+ public const STATUS_TODO = 'todo';
+ public const STATUS_DOING = 'doing';
+ public const STATUS_DONE = 'done';
- const TRANSITION_START = 'start';
- const TRANSITION_FINISH = 'finish';
- const TRANSITION_CANCEL = 'cancel';
- const TRANSITION_RESET = 'reset';
+ public const TRANSITION_START = 'start';
+ public const TRANSITION_FINISH = 'finish';
+ public const TRANSITION_CANCEL = 'cancel';
+ public const TRANSITION_RESET = 'reset';
#[ORM\Id]
#[ORM\GeneratedValue]
@@ -351,5 +351,4 @@ class Task
return $this;
}
-
}
diff --git a/src/EventSubscriber/TaskLifecycleSubscriber.php b/src/EventSubscriber/TaskLifecycleSubscriber.php
index 34ab654..9617132 100644
--- a/src/EventSubscriber/TaskLifecycleSubscriber.php
+++ b/src/EventSubscriber/TaskLifecycleSubscriber.php
@@ -19,7 +19,6 @@ use Twig\Environment;
// circonstances
class TaskLifecycleSubscriber implements EventSubscriberInterface
{
-
public function __construct(
protected EntityManagerInterface $entityManager,
protected Environment $twig,
@@ -78,7 +77,7 @@ class TaskLifecycleSubscriber implements EventSubscriberInterface
}
$event->setBlocked(false);
- }
+ }
// Cas où on commence une tâche
public function onStart(Event $event): void
@@ -130,5 +129,4 @@ class TaskLifecycleSubscriber implements EventSubscriberInterface
EnteredEvent::getName('task_lifecycle', Task::STATUS_DONE) => 'onDone',
];
}
-
}
diff --git a/src/Form/CommentType.php b/src/Form/CommentType.php
index 8571199..512d01c 100644
--- a/src/Form/CommentType.php
+++ b/src/Form/CommentType.php
@@ -3,8 +3,6 @@
namespace App\Form;
use App\Entity\Comment;
-use App\Entity\Task;
-use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
diff --git a/src/Form/CsvType.php b/src/Form/CsvType.php
index 9920aa2..3701a11 100644
--- a/src/Form/CsvType.php
+++ b/src/Form/CsvType.php
@@ -5,7 +5,6 @@ namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
-use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\File;
class CsvType extends AbstractType
@@ -24,7 +23,7 @@ class CsvType extends AbstractType
'text/plain',
],
'mimeTypesMessage' => 'Type MIME inattendu',
- ])
+ ]),
],
'help' => 'Fichier CSV classique (encodé en UTF8, séparé par des virgules, entouré avec des doubles guillemets, échappé avec des barres obliques et avec des retours chariots UNIX) contenant une ligne de noms de colonnes « name,description,osm,geojson,status » et enfin dans la colonne « status » la valeur « todo », « doing » ou « done ».',
])
diff --git a/src/Form/TaskLifecycleType.php b/src/Form/TaskLifecycleType.php
index 8d1b338..3ef91a9 100644
--- a/src/Form/TaskLifecycleType.php
+++ b/src/Form/TaskLifecycleType.php
@@ -2,12 +2,10 @@
namespace App\Form;
-use App\Entity\Task;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Workflow\WorkflowInterface;
-use Symfony\Component\DependencyInjection\Attribute\Target;
class TaskLifecycleType extends AbstractType
{
diff --git a/src/Form/TaskType.php b/src/Form/TaskType.php
index 2ea3b0f..ffe3672 100644
--- a/src/Form/TaskType.php
+++ b/src/Form/TaskType.php
@@ -3,7 +3,6 @@
namespace App\Form;
use App\Entity\Task;
-use App\Form\TaskLifecycleType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -33,7 +32,7 @@ class TaskType extends AbstractType
'help' => 'XML décrivant ce qu’il faut charger dans la feuille de données de JOSM (cf FR:OSM XML - OpenStreetMap Wiki)',
])
->add('status', TaskLifecycleType::class, [
- 'label' => 'État'
+ 'label' => 'État',
])
->add('urgent', null, [
'label' => 'Urgence',
diff --git a/src/Repository/CommentRepository.php b/src/Repository/CommentRepository.php
index e26232e..85db5ab 100644
--- a/src/Repository/CommentRepository.php
+++ b/src/Repository/CommentRepository.php
@@ -2,9 +2,8 @@
namespace App\Repository;
-use App\Entity\Task;
-use App\Entity\Project;
use App\Entity\Comment;
+use App\Entity\Project;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -30,7 +29,7 @@ class CommentRepository extends ServiceEntityRepository
->orderBy('c.createdAt', 'DESC')
->getQuery()
->getResult()
- ;
+ ;
}
// public function findOneBySomeField($value): ?Comment
diff --git a/src/Repository/TaskRepository.php b/src/Repository/TaskRepository.php
index cac1993..134ab46 100644
--- a/src/Repository/TaskRepository.php
+++ b/src/Repository/TaskRepository.php
@@ -9,7 +9,7 @@ use Doctrine\Persistence\ManagerRegistry;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
-
+
/**
* @extends ServiceEntityRepository
*/
@@ -76,7 +76,7 @@ class TaskRepository extends ServiceEntityRepository
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
- ;
+ ;
}
public function findRandomByProject(Project $project, $status = null)
@@ -92,11 +92,10 @@ class TaskRepository extends ServiceEntityRepository
$tasks = $qb->getQuery()
->getResult()
- ;
+ ;
shuffle($tasks);
- return reset($tasks);
- }
-
+ return reset($tasks);
+ }
}
diff --git a/src/Security/OpenStreetMapAuthenticator.php b/src/Security/OpenStreetMapAuthenticator.php
index eb4c50b..90714dd 100644
--- a/src/Security/OpenStreetMapAuthenticator.php
+++ b/src/Security/OpenStreetMapAuthenticator.php
@@ -2,7 +2,7 @@
namespace App\Security;
-use App\Entity\User;
+use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use KnpU\OAuth2ClientBundle\Security\Authenticator\OAuth2Authenticator;
@@ -17,19 +17,18 @@ use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
-class OpenStreetMapAuthenticator extends OAuth2Authenticator implements AuthenticationEntrypointInterface
+class OpenStreetMapAuthenticator extends OAuth2Authenticator implements AuthenticationEntryPointInterface
{
public function __construct(
private ClientRegistry $clientRegistry,
private EntityManagerInterface $entityManager,
private RouterInterface $router,
- )
- {
+ ) {
}
public function supports(Request $request): ?bool
{
- return $request->attributes->get('_route') === 'app_osm_callback';
+ return 'app_osm_callback' === $request->attributes->get('_route');
}
public function authenticate(Request $request): Passport
@@ -41,7 +40,7 @@ class OpenStreetMapAuthenticator extends OAuth2Authenticator implements Authenti
$session->set('access_token', $accessToken);
return new SelfValidatingPassport(
- new UserBadge($accessToken->getToken(), function() use ($accessToken, $client) {
+ new UserBadge($accessToken->getToken(), function () use ($accessToken, $client) {
$resourceOwner = $client->fetchUserFromToken($accessToken);
$existingUser = $this->entityManager->getRepository(User::class)->findOneBy(['osmId' => $resourceOwner->getId()]);
@@ -72,8 +71,8 @@ class OpenStreetMapAuthenticator extends OAuth2Authenticator implements Authenti
{
return null;
}
-
- public function start(Request $request, AuthenticationException $authException = null): Response
+
+ public function start(Request $request, ?AuthenticationException $authException = null): Response
{
return new RedirectResponse(
'/',
diff --git a/src/Service/GeoJsonManager.php b/src/Service/GeoJsonManager.php
index 5225445..a611ba1 100644
--- a/src/Service/GeoJsonManager.php
+++ b/src/Service/GeoJsonManager.php
@@ -10,7 +10,6 @@ use Symfony\Component\Workflow\WorkflowInterface;
class GeoJsonManager
{
-
public function __construct(
private UrlGeneratorInterface $router,
private WorkflowInterface $taskLifecycleStateMachine,
@@ -32,12 +31,12 @@ class GeoJsonManager
if (!isset($data['features']) or empty($data['features'])) {
return null;
- }
+ }
- foreach($data['features'] as $index => $feature) {
+ foreach ($data['features'] as $index => $feature) {
if (!isset($feature['properties'])) {
continue;
- }
+ }
$feature['properties'] = array_merge($feature['properties'], [
'name' => $task->getName(),
'url' => $this->router->generate('app_task_show', ['slug' => $task->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
@@ -45,12 +44,12 @@ class GeoJsonManager
]);
$data['features'][$index] = $feature;
}
-
+
return $data;
}
// Produit le geojson d’un projet ou d’une tâche de façon transparente pour simplifier
- public function generateGeoJson($entity)
+ public function generateGeoJson($entity)
{
$geoJsons = [];
@@ -72,5 +71,4 @@ class GeoJsonManager
return $geoJsons;
}
-
}
diff --git a/src/Service/OpenStreetMapClient.php b/src/Service/OpenStreetMapClient.php
index de62a50..513fddd 100644
--- a/src/Service/OpenStreetMapClient.php
+++ b/src/Service/OpenStreetMapClient.php
@@ -7,8 +7,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\HttpClient\HttpClientInterface;
// Fournit un accès à l’API OSM
-class OpenStreetMapClient {
-
+class OpenStreetMapClient
+{
public function __construct(
private ClientRegistry $clientRegistry,
private HttpClientInterface $client,
@@ -28,12 +28,12 @@ class OpenStreetMapClient {
*/
$token = $accessToken->getToken();
- $response = $this->client->request($method, 'https://api.openstreetmap.org/api/0.6/' . $path, [
+ $response = $this->client->request($method, 'https://api.openstreetmap.org/api/0.6/'.$path, [
'auth_bearer' => $token,
'query' => $params,
]);
- $isStatusCodeOk = ($response->getStatusCode() === 200);
+ $isStatusCodeOk = (200 === $response->getStatusCode());
if (!$isStatusCodeOk) {
throw new \RuntimeException();
@@ -81,5 +81,4 @@ class OpenStreetMapClient {
return $changesets;
}
-
}
diff --git a/src/Service/OsmoseClient.php b/src/Service/OsmoseClient.php
index 3de2e09..636d6f5 100644
--- a/src/Service/OsmoseClient.php
+++ b/src/Service/OsmoseClient.php
@@ -22,11 +22,10 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
// Fournira un accès à l’API Osmose si nécessaire (histoire de vérifier qu’on a
// pas trop oublié de tenir compte de la validation côté JOSM lors de la
// contribution sur une tâche ?)
-class OsmoseClient {
-
+class OsmoseClient
+{
public function __construct(
private HttpClientInterface $client,
) {
}
-
}
diff --git a/src/Service/OverpassClient.php b/src/Service/OverpassClient.php
index 38f0738..3c795b3 100644
--- a/src/Service/OverpassClient.php
+++ b/src/Service/OverpassClient.php
@@ -5,8 +5,8 @@ namespace App\Service;
use Symfony\Contracts\HttpClient\HttpClientInterface;
// Founit un accès à l’API Overpass
-class OverpassClient {
-
+class OverpassClient
+{
public function __construct(
private HttpClientInterface $client,
) {
@@ -16,12 +16,12 @@ class OverpassClient {
{
$response = $this->client->request('GET', 'https://overpass-api.de/api/interpreter', [
'query' => [
- 'data' => $prefix . $query . $suffix,
+ 'data' => $prefix.$query.$suffix,
],
]);
- $isStatusCodeOk = ($response->getStatusCode() === 200);
- $isContentTypeJson = ($response->getHeaders()['content-type'][0] === 'application/json');
+ $isStatusCodeOk = (200 === $response->getStatusCode());
+ $isContentTypeJson = ('application/json' === $response->getHeaders()['content-type'][0]);
if (!$isStatusCodeOk or !$isContentTypeJson) {
throw new \RuntimeException();
@@ -29,5 +29,4 @@ class OverpassClient {
return $response->getContent();
}
-
}
diff --git a/src/Service/SourceGenerator.php b/src/Service/SourceGenerator.php
index d206df2..9ec3c8b 100644
--- a/src/Service/SourceGenerator.php
+++ b/src/Service/SourceGenerator.php
@@ -7,7 +7,6 @@ use App\Entity\Task;
// Génère la source de changeset
class SourceGenerator
{
-
public function generate(Task $task): string
{
$parts = [];
@@ -17,7 +16,7 @@ class SourceGenerator
$parts[] = $project->getName();
$parts[] = $task->getName();
- foreach(explode(' ', $project->getHashtags()) as $hashtag) {
+ foreach (explode(' ', $project->getHashtags()) as $hashtag) {
$parts[] = $hashtag;
}
@@ -25,5 +24,4 @@ class SourceGenerator
return $source;
}
-
}
diff --git a/src/Service/TaskLifecycleManager.php b/src/Service/TaskLifecycleManager.php
index e36a6ec..1e40f68 100644
--- a/src/Service/TaskLifecycleManager.php
+++ b/src/Service/TaskLifecycleManager.php
@@ -9,7 +9,6 @@ use Symfony\Component\Workflow\WorkflowInterface;
// Utilistaire pour récupérer facilement les stats de réalisation d’un projet ou d’une tâche
class TaskLifecycleManager
{
-
public function __construct(
private WorkflowInterface $taskLifecycleStateMachine,
) {
@@ -41,13 +40,12 @@ class TaskLifecycleManager
}
$max = 0;
- foreach ($project->getTasks() as $task)
- {
- $stats[$task->getStatus()]['value'] += 1;
- $max += 1;
+ foreach ($project->getTasks() as $task) {
+ ++$stats[$task->getStatus()]['value'];
+ ++$max;
}
- if ($max === 0) {
+ if (0 === $max) {
return $stats;
}
@@ -56,10 +54,8 @@ class TaskLifecycleManager
$data['percentage'] = ((float) $data['value'] * 100.0) / $max;
return $data;
- }, $stats);
+ }, $stats);
return $stats;
}
-
-
}