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