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.

Mailer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
B __invoke() 0 28 2
1
<?php
2
namespace RbComment\Mvc\Controller\Plugin;
3
4
use Zend\Mail\Message;
5
use Zend\Mime\Part as MimePart;
6
use Zend\Mime\Message as MimeMessage;
7
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
8
9
class Mailer extends AbstractPlugin
10
{
11
    private $serverUrlHelper;
12
    private $mailerService;
13
    private $configService;
14
15
    public function __construct(
16
        $serverUrlHelper,
17
        $mailerService,
18
        array $configService
19
    ) {
20
        $this->serverUrlHelper = $serverUrlHelper;
21
        $this->mailerService   = $mailerService;
22
        $this->configService   = $configService;
23
    }
24
25
    public function __invoke($comment)
26
    {
27
        $mailerConfig = $this->configService['rb_comment']['email'];
28
29
        $htmlContent = $comment->content;
30
        $htmlContent .= '<br><br>';
31
        $htmlContent .=
32
            '<a href="' . $this->serverUrlHelper->__invoke() . $comment->uri . '#rbcomment-' . $comment->id . '">' .
33
                $mailerConfig['context_link_text'] .
34
            '</a>';
35
36
        $html = new MimePart($htmlContent);
37
        $html->type = "text/html";
38
39
        $body = new MimeMessage();
40
        $body->setParts([$html]);
41
42
        $message = new Message();
43
        $message->addFrom($mailerConfig['from'])
44
                ->setSubject($mailerConfig['subject'])
45
                ->setBody($body);
46
47
        foreach ($mailerConfig['to'] as $mConfig) {
48
            $message->addTo($mConfig);
49
        }
50
51
        $this->mailerService->send($message);
52
    }
53
}
54