mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 20:43:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -29,7 +29,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use function count;
|
||||
|
||||
final readonly class CalendarContext implements CalendarContextInterface
|
||||
{
|
||||
@@ -122,8 +121,6 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function getData(DocGeneratorTemplate $template, mixed $entity, array $contextGenerationData = []): array
|
||||
{
|
||||
$options = $this->getOptions($template);
|
||||
@@ -173,7 +170,7 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
if ($options['askMainPerson']) {
|
||||
$data['mainPerson'] = null;
|
||||
|
||||
if (1 === count($entity->getPersons())) {
|
||||
if (1 === \count($entity->getPersons())) {
|
||||
$data['mainPerson'] = $entity->getPersons()->first();
|
||||
}
|
||||
}
|
||||
@@ -181,7 +178,7 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
if ($options['askThirdParty']) {
|
||||
$data['thirdParty'] = null;
|
||||
|
||||
if (1 === count($entity->getProfessionals())) {
|
||||
if (1 === \count($entity->getProfessionals())) {
|
||||
$data['thirdParty'] = $entity->getProfessionals()->first();
|
||||
}
|
||||
}
|
||||
|
@@ -12,12 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @extends DocGeneratorContextWithPublicFormInterface<Calendar>
|
||||
|
@@ -22,7 +22,6 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
@@ -44,7 +43,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
/**
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -91,7 +90,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod);
|
||||
}
|
||||
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -136,8 +135,8 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
$storedObjectMetadata->getColumnName('createdAt')
|
||||
);
|
||||
$orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(),
|
||||
DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
\DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
$orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE];
|
||||
}
|
||||
|
||||
@@ -147,7 +146,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->addWhereClause(implode(" OR ", $or), $orParams, $orTypes);
|
||||
$query->addWhereClause(implode(' OR ', $or), $orParams, $orTypes);
|
||||
|
||||
return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content);
|
||||
}
|
||||
@@ -159,7 +158,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
|
||||
}
|
||||
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): FetchQuery
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): FetchQuery
|
||||
{
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
|
||||
@@ -182,7 +181,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
if (null !== $content) {
|
||||
$query->addWhereClause(
|
||||
sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')),
|
||||
['%' . $content . '%'],
|
||||
['%'.$content.'%'],
|
||||
[Types::STRING]
|
||||
);
|
||||
}
|
||||
|
@@ -19,8 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
@@ -28,7 +26,7 @@ use Service\GenericDoc\Providers\PersonCalendarGenericDocProviderTest;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* Provide calendar documents for calendar associated to persons
|
||||
* Provide calendar documents for calendar associated to persons.
|
||||
*
|
||||
* @see PersonCalendarGenericDocProviderTest
|
||||
*/
|
||||
@@ -41,7 +39,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
private EntityManagerInterface $em
|
||||
) {}
|
||||
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
||||
private function addWhereClausesToQuery(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||
{
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
|
||||
@@ -64,7 +62,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
if (null !== $content) {
|
||||
$query->addWhereClause(
|
||||
sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')),
|
||||
['%' . $content . '%'],
|
||||
['%'.$content.'%'],
|
||||
[Types::STRING]
|
||||
);
|
||||
}
|
||||
@@ -75,7 +73,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
/**
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -114,10 +112,6 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowedForPerson(Person $person): bool
|
||||
{
|
||||
return $this->security->isGranted(CalendarVoter::SEE, $person);
|
||||
|
@@ -23,7 +23,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocRenderer implements Gen
|
||||
|
||||
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
||||
{
|
||||
return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY || $genericDocDTO->key === PersonCalendarGenericDocProvider::KEY;
|
||||
return AccompanyingPeriodCalendarGenericDocProvider::KEY === $genericDocDTO->key || PersonCalendarGenericDocProvider::KEY === $genericDocDTO->key;
|
||||
}
|
||||
|
||||
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
||||
|
@@ -19,7 +19,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
@@ -33,7 +32,7 @@ class BulkCalendarShortMessageSender
|
||||
$countCalendars = 0;
|
||||
$countSms = 0;
|
||||
|
||||
foreach ($this->provider->getCalendars(new DateTimeImmutable('now')) as $calendar) {
|
||||
foreach ($this->provider->getCalendars(new \DateTimeImmutable('now')) as $calendar) {
|
||||
$smses = $this->messageForCalendarBuilder->buildMessageForCalendar($calendar);
|
||||
|
||||
foreach ($smses as $sms) {
|
||||
@@ -42,13 +41,13 @@ class BulkCalendarShortMessageSender
|
||||
}
|
||||
|
||||
$this->em
|
||||
->createQuery('UPDATE ' . Calendar::class . ' c SET c.smsStatus = :smsStatus WHERE c.id = :id')
|
||||
->createQuery('UPDATE '.Calendar::class.' c SET c.smsStatus = :smsStatus WHERE c.id = :id')
|
||||
->setParameters(['smsStatus' => Calendar::SMS_SENT, 'id' => $calendar->getId()])
|
||||
->execute();
|
||||
++$countCalendars;
|
||||
$this->em->refresh($calendar);
|
||||
}
|
||||
|
||||
$this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]);
|
||||
$this->logger->info(self::class.'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]);
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,7 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use function count;
|
||||
|
||||
class CalendarForShortMessageProvider
|
||||
{
|
||||
@@ -35,7 +33,7 @@ class CalendarForShortMessageProvider
|
||||
*
|
||||
* @return iterable|Calendar[]
|
||||
*/
|
||||
public function getCalendars(DateTimeImmutable $at): iterable
|
||||
public function getCalendars(\DateTimeImmutable $at): iterable
|
||||
{
|
||||
$range = $this->rangeGenerator->generateRange($at);
|
||||
|
||||
@@ -62,6 +60,6 @@ class CalendarForShortMessageProvider
|
||||
|
||||
$calendars = $this->calendarRepository
|
||||
->findByNotificationAvailable($startDate, $endDate, $batchSize, $offset);
|
||||
} while (count($calendars) === $batchSize);
|
||||
} while (\count($calendars) === $batchSize);
|
||||
}
|
||||
}
|
||||
|
@@ -18,9 +18,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use DateInterval;
|
||||
use Monolog\DateTimeImmutable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* * Lundi => Envoi des rdv du mardi et mercredi.
|
||||
@@ -33,7 +31,7 @@ class DefaultRangeGenerator implements RangeGeneratorInterface
|
||||
{
|
||||
public function generateRange(\DateTimeImmutable $date): ?array
|
||||
{
|
||||
$onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d') . ' 00:00:00');
|
||||
$onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d').' 00:00:00');
|
||||
|
||||
switch ($dow = (int) $onMidnight->format('w')) {
|
||||
case 6: // Saturday
|
||||
@@ -42,32 +40,32 @@ class DefaultRangeGenerator implements RangeGeneratorInterface
|
||||
|
||||
case 1: // Monday
|
||||
// send for Tuesday and Wednesday
|
||||
$startDate = $onMidnight->add(new DateInterval('P1D'));
|
||||
$endDate = $startDate->add(new DateInterval('P2D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P1D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P2D'));
|
||||
|
||||
break;
|
||||
|
||||
case 2: // tuesday
|
||||
case 3: // wednesday
|
||||
$startDate = $onMidnight->add(new DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new DateInterval('P1D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P1D'));
|
||||
|
||||
break;
|
||||
|
||||
case 4: // thursday
|
||||
$startDate = $onMidnight->add(new DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new DateInterval('P2D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P2D'));
|
||||
|
||||
break;
|
||||
|
||||
case 5: // friday
|
||||
$startDate = $onMidnight->add(new DateInterval('P3D'));
|
||||
$endDate = $startDate->add(new DateInterval('P1D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P3D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P1D'));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('a day of a week should not have the value: ' . $dow);
|
||||
throw new \UnexpectedValueException('a day of a week should not have the value: '.$dow);
|
||||
}
|
||||
|
||||
return ['startDate' => $startDate, 'endDate' => $endDate];
|
||||
|
@@ -20,7 +20,6 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Service\ShortMessage\ShortMessage;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface
|
||||
{
|
||||
|
@@ -18,12 +18,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
interface RangeGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @return ?array{startDate: DateTimeImmutable, endDate: DateTimeImmutable} when return is null, then no ShortMessage must be send
|
||||
* @return ?array{startDate: \DateTimeImmutable, endDate: \DateTimeImmutable} when return is null, then no ShortMessage must be send
|
||||
*/
|
||||
public function generateRange(DateTimeImmutable $date): ?array;
|
||||
public function generateRange(\DateTimeImmutable $date): ?array;
|
||||
}
|
||||
|
Reference in New Issue
Block a user