DX: fix cs

This commit is contained in:
Julien Fastré 2023-02-06 17:47:54 +01:00
parent 4b2c330d22
commit 70871176fc
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
29 changed files with 100 additions and 74 deletions

View File

@ -58,7 +58,8 @@ class DateAggregator implements AggregatorInterface
break; break;
case 'year': case 'year':
$fmt = 'YYYY'; $order = 'DESC'; $fmt = 'YYYY';
$order = 'DESC';
break; // order DESC does not works ! break; // order DESC does not works !

View File

@ -53,6 +53,11 @@ class ResourceKindRepository implements ObjectRepository
->getResult(); ->getResult();
} }
public function findOneByKind(string $kind): ?ResourceKind
{
return $this->repository->findOneBy(['kind' => $kind]) ;
}
/** /**
* @return ResourceType[] * @return ResourceType[]
*/ */

View File

@ -512,7 +512,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/ */
public function getUsers(): Collection public function getUsers(): Collection
{ {
return $this->getInvites()->map(static function (Invite $i) { return $i->getUser(); }); return $this->getInvites()->map(static function (Invite $i) {
return $i->getUser();
});
} }
public function hasCalendarRange(): bool public function hasCalendarRange(): bool
@ -597,7 +599,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
} }
$invite = $this->invites $invite = $this->invites
->filter(static function (Invite $invite) use ($user) { return $invite->getUser() === $user; }) ->filter(static function (Invite $invite) use ($user) {
return $invite->getUser() === $user;
})
->first(); ->first();
$this->removeInvite($invite); $this->removeInvite($invite);

View File

@ -89,10 +89,14 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
$newInvites = array_filter( $newInvites = array_filter(
array_map( array_map(
function ($id) { return $this->inviteRepository->find($id); }, function ($id) {
return $this->inviteRepository->find($id);
},
$calendarMessage->getNewInvitesIds(), $calendarMessage->getNewInvitesIds(),
), ),
static function (?Invite $invite) { return null !== $invite; } static function (?Invite $invite) {
return null !== $invite;
}
); );
$this->calendarConnector->syncCalendar( $this->calendarConnector->syncCalendar(

View File

@ -167,7 +167,9 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
] ]
)->toArray(); )->toArray();
$ids = array_map(static function ($item) { return $item['id']; }, $bareEvents['value']); $ids = array_map(static function ($item) {
return $item['id'];
}, $bareEvents['value']);
$existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids);
$existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids);

View File

@ -114,8 +114,12 @@ final class CalendarTypeTest extends TypeTestCase
$this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(8, $calendar->getCalendarRange()->getId());
$this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId());
$this->assertEquals(true, $calendar->getSendSMS()); $this->assertEquals(true, $calendar->getSendSMS());
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); })); $this->assertContains(2, $calendar->getUsers()->map(static function (User $u) {
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); })); return $u->getId();
}));
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) {
return $u->getId();
}));
} }
protected function getExtensions() protected function getExtensions()
@ -147,7 +151,9 @@ final class CalendarTypeTest extends TypeTestCase
->will(static function ($args) { ->will(static function ($args) {
return implode( return implode(
',', ',',
array_map(static function ($p) { return $p->getId(); }, $args[0]) array_map(static function ($p) {
return $p->getId();
}, $args[0])
); );
}); });
$transformer->transform(Argument::exact(null)) $transformer->transform(Argument::exact(null))
@ -156,7 +162,9 @@ final class CalendarTypeTest extends TypeTestCase
->will(static function ($args) { ->will(static function ($args) {
return implode( return implode(
',', ',',
array_map(static function ($p) { return $p->getId(); }, $args[0]->toArray()) array_map(static function ($p) {
return $p->getId();
}, $args[0]->toArray())
); );
}); });
$transformer->reverseTransform(Argument::type('string')) $transformer->reverseTransform(Argument::type('string'))

View File

@ -42,7 +42,9 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{ {
$this->repository = $repository; $this->repository = $repository;
$this->multiple = $multiple; $this->multiple = $multiple;
$this->getId = $getId ?? static function (object $o) { return $o->getId(); }; $this->getId = $getId ?? static function (object $o) {
return $o->getId();
};
} }
/** /**