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