From c4e2ae721e87d2451700282535283edfcf6dc81c Mon Sep 17 00:00:00 2001 From: ewandor Date: Sat, 8 Jul 2023 12:49:47 +0200 Subject: [PATCH] Correcting PHPCS and PHPStan comments --- .../UnsettledSentenceController.php | 18 +++++++------- src/Entity/Criminal.php | 12 +++++----- src/Entity/SentenceSettlement.php | 9 ++----- src/Form/CriminalType.php | 24 +++++++++++++++---- src/Form/SentenceSettlementType.php | 3 --- src/Repository/CriminalRepository.php | 3 ++- 6 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/Controller/UnsettledSentenceController.php b/src/Controller/UnsettledSentenceController.php index f7deaa3..5517742 100644 --- a/src/Controller/UnsettledSentenceController.php +++ b/src/Controller/UnsettledSentenceController.php @@ -2,16 +2,12 @@ namespace App\Controller; -use App\Entity\Criminal; -use App\Entity\Directory; use App\Entity\SentenceSettlement; -use App\Entity\User; use App\Form\SearchBarType; use App\Form\SentenceSettlementType; use App\Repository\CriminalRepository; -use App\Repository\DirectoryRepository; -use Doctrine\ORM\EntityManagerInterface; use Knp\Component\Pager\PaginatorInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormError; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -21,6 +17,13 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; #[Route('/unsettled_sentence', name: 'unsettled_sentence_')] class UnsettledSentenceController extends AbstractController { + private LoggerInterface $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + #[Route('/list/{type?*}', name: 'list')] public function list( PaginatorInterface $paginator, @@ -50,9 +53,8 @@ class UnsettledSentenceController extends AbstractController $form = $this->createForm( SentenceSettlementType::class, $sentence, - [ - 'action'=> $this->generateUrl('unsettled_sentence_settle'), - ]); + ['action' => $this->generateUrl('unsettled_sentence_settle'),] + ); $pagination[$i]->form = $form->createView(); } diff --git a/src/Entity/Criminal.php b/src/Entity/Criminal.php index dfbfe0a..025ee24 100644 --- a/src/Entity/Criminal.php +++ b/src/Entity/Criminal.php @@ -2,7 +2,7 @@ namespace App\Entity; -use \OutOfRangeException; +use OutOfRangeException; use App\Entity\Document; use Doctrine\ORM\Mapping as ORM; use App\Repository\CriminalRepository; @@ -14,9 +14,9 @@ use Symfony\Component\Validator\Constraints as Assert; */ class Criminal extends Document { - const TYPE_JAIL = 'jail'; - const TYPE_FINE = 'fine'; - const TYPE_COMMUNITY_WORK = 'community_work'; + public const TYPE_JAIL = 'jail'; + public const TYPE_FINE = 'fine'; + public const TYPE_COMMUNITY_WORK = 'community_work'; /** * @ORM\ManyToOne(targetEntity=Directory::class, inversedBy="criminals") @@ -172,7 +172,8 @@ class Criminal extends Document return $this; } - public function addSettlement($type, $amount) { + public function addSettlement($type, $amount) + { if ($type == Criminal::TYPE_FINE) { if ($this->getAmountMoney() - $this->getAmountMoneySettled() < $amount) { throw new OutOfRangeException(); @@ -183,7 +184,6 @@ class Criminal extends Document throw new OutOfRangeException(); } $this->setAmountTimeSettled($this->getAmountTimeSettled() + $amount); - } elseif ($type == Criminal::TYPE_COMMUNITY_WORK) { if ($this->getAmountCommunityWork() - $this->getAmountCommunityWorkSettled() < $amount) { throw new OutOfRangeException(); diff --git a/src/Entity/SentenceSettlement.php b/src/Entity/SentenceSettlement.php index d3c207c..5f8742a 100644 --- a/src/Entity/SentenceSettlement.php +++ b/src/Entity/SentenceSettlement.php @@ -4,10 +4,6 @@ namespace App\Entity; class SentenceSettlement { - const TYPE_JAIL = 'jail'; - const TYPE_FINE = 'fine'; - const TYPE_COMMUNITY_WORK = 'community_work'; - private Criminal $criminal; private string $type; private $amount = null; @@ -15,8 +11,7 @@ class SentenceSettlement public function __construct( Criminal $criminal, string $type - ) - { + ) { $this->criminal = $criminal; $this->type = $type; } @@ -76,4 +71,4 @@ class SentenceSettlement { $this->amount = $amount; } -} \ No newline at end of file +} diff --git a/src/Form/CriminalType.php b/src/Form/CriminalType.php index 900323a..0dccf5e 100644 --- a/src/Form/CriminalType.php +++ b/src/Form/CriminalType.php @@ -20,10 +20,26 @@ class CriminalType extends DocumentType ->add('content', ContentType::class, ['label' => 'form_label_informations' ]) ->add('amountMoney', null, ['label' => 'form_label_amount', 'help' => 'form_help_amount']) ->add('amountTime', null, ['label' => 'form_label_time', 'help' => 'form_help_time']) - ->add('amountCommunityWork', null, ['label' => 'form_label_community_work', 'help' => 'form_help_community_work']) - ->add('amountMoneySettled', null, ['label' => 'form_label_amount_settled', 'help' => 'form_help_amount_settled']) - ->add('amountTimeSettled', null, ['label' => 'form_label_time_settled', 'help' => 'form_help_time_settled']) - ->add('amountCommunityWorkSettled', null, ['label' => 'form_label_community_work_settled', 'help' => 'form_help_community_work_settled']) + ->add( + 'amountCommunityWork', + null, + ['label' => 'form_label_community_work', 'help' => 'form_help_community_work'] + ) + ->add( + 'amountMoneySettled', + null, + ['label' => 'form_label_amount_settled', 'help' => 'form_help_amount_settled'] + ) + ->add( + 'amountTimeSettled', + null, + ['label' => 'form_label_time_settled', 'help' => 'form_help_time_settled'] + ) + ->add( + 'amountCommunityWorkSettled', + null, + ['label' => 'form_label_community_work_settled', 'help' => 'form_help_community_work_settled'] + ) ; } diff --git a/src/Form/SentenceSettlementType.php b/src/Form/SentenceSettlementType.php index d686ff3..71a6cda 100644 --- a/src/Form/SentenceSettlementType.php +++ b/src/Form/SentenceSettlementType.php @@ -54,7 +54,4 @@ class SentenceSettlementType extends AbstractType { return ''; // return an empty string here } - - - } diff --git a/src/Repository/CriminalRepository.php b/src/Repository/CriminalRepository.php index 37c06e7..bbe80a1 100644 --- a/src/Repository/CriminalRepository.php +++ b/src/Repository/CriminalRepository.php @@ -20,7 +20,8 @@ class CriminalRepository extends DocumentRepositoriesExtension $this->fields = ['amountMoney', 'amountTime', 'content']; //with title, list fields we can search in } - public function limitUnsettled(string $type) { + public function limitUnsettled(string $type) + { if ($type == Criminal::TYPE_FINE) { $column = 'd.amountMoney'; } elseif ($type == Criminal::TYPE_JAIL) {