Completed
Push — master ( 7ee0d9...1aff7f )
by Rafał
24:06 queued 15:30
created

ReportMailer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A sendReportReadyEmailNotification() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Core Bundle.
7
 *
8
 * Copyright 2020 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2020 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\CoreBundle\AnalyticsExport;
18
19
use Symfony\Component\Mailer\MailerInterface;
20
use Symfony\Component\Mime\Email;
21
22
final class ReportMailer
23
{
24
    /** @var MailerInterface */
25
    private $mailer;
26
27
    /** @var string */
28
    private $fromEmail;
29
30
    public function __construct(MailerInterface $mailer, string $fromEmail)
31
    {
32
        $this->mailer = $mailer;
33
        $this->fromEmail = $fromEmail;
34
    }
35
36
    public function sendReportReadyEmailNotification(string $email, string $reportUrl): void
37
    {
38
        $emailObject = (new Email())
39
            ->from($this->fromEmail)
40
            ->to($email)
41
            ->subject('Your report is ready!')
42
            ->text("You can download your report here $reportUrl");
43
44
        $this->mailer->send($emailObject);
45
    }
46
}
47