GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f98089...b28a0d )
by Mario
36:02
created

BaseEmailAction::throwException()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Core\Action;
6
7
use Netgen\InformationCollection\API\Action\ActionInterface;
8
use Netgen\InformationCollection\API\Exception\EmailNotSentException;
9
use Netgen\InformationCollection\API\MailerInterface;
10
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
11
use Netgen\InformationCollection\Core\Factory\BaseEmailDataFactory;
12
13
abstract class BaseEmailAction implements ActionInterface
14
{
15
    /**
16
     * @var \Netgen\InformationCollection\API\MailerInterface
17
     */
18
    protected $mailer;
19
20
    /**
21
     * @var \Netgen\InformationCollection\Core\Factory\BaseEmailDataFactory
22
     */
23
    protected $factory;
24
25
    /**
26
     * EmailAction constructor.
27
     *
28
     * @param \Netgen\InformationCollection\API\MailerInterface $mailer
29
     * @param \Netgen\InformationCollection\Core\Factory\BaseEmailDataFactory $factory
30
     */
31
    public function __construct(MailerInterface $mailer, BaseEmailDataFactory $factory)
32
    {
33
        $this->mailer = $mailer;
34
        $this->factory = $factory;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function act(InformationCollected $event): void
41
    {
42
        $emailData = $this->factory->build($event);
43
44
        try {
45
            $this->mailer->createAndSendMessage($emailData);
46
        } catch (EmailNotSentException $e) {
47
            $this->throwException($e);
48
        }
49
    }
50
51
    abstract protected function throwException(EmailNotSentException $exception);
52
}
53