| Conditions | 2 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 2.0094 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 1 | public static function build(): iterable |
|
| 17 | { |
||
| 18 | 1 | yield 'subscribeNewsletter' => fn () => [ |
|
| 19 | 1 | 'type' => Type::nonNull(Type::boolean()), |
|
| 20 | 1 | 'description' => 'Subscribe to newsletter.', |
|
| 21 | 1 | 'args' => [ |
|
| 22 | 1 | 'email' => Type::nonNull(_types()->get(EmailType::class)), |
|
| 23 | 1 | ], |
|
| 24 | 1 | 'resolve' => function ($root, array $args, SessionInterface $session): bool { |
|
| 25 | 1 | $email = $args['email']; |
|
| 26 | global $container; |
||
| 27 | /** @var Mailer $mailer */ |
||
| 28 | 1 | $mailer = $container->get(Mailer::class); |
|
| 29 | |||
| 30 | /** @var MessageQueuer $messageQueuer */ |
||
| 31 | 1 | $messageQueuer = $container->get(MessageQueuer::class); |
|
| 32 | |||
| 33 | 1 | foreach ($messageQueuer->getAllEmailsToNotify() as $adminEmail) { |
|
| 34 | $message = $messageQueuer->queueNewsletterSubscription($adminEmail, $email); |
||
| 35 | $mailer->sendMessageAsync($message); |
||
| 36 | } |
||
| 37 | |||
| 38 | 1 | return true; |
|
| 39 | 1 | }, |
|
| 43 |