Correcting PHPCS and PHPStan comments
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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']
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,4 @@ class SentenceSettlementType extends AbstractType
|
||||
{
|
||||
return ''; // return an empty string here
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user