mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 00:55:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -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