Completed
Push — dev-master ( 1290b8...c91af7 )
by Derek Stephen
07:37
created

TestController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace BoneMvc\Module\Test\Controller;
4
5
use Bone\Mvc\View\ViewEngine;
6
use BoneMvc\Mail\EmailMessage;
7
use BoneMvc\Mail\Service\MailService;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Zend\Diactoros\Response\HtmlResponse;
11
12
class TestController
13
{
14
    /** @var ViewEngine $view */
15
    private $view;
16
17
    /** @var MailService $mailService */
18
    private $mailService;
19
20
    public function __construct(ViewEngine $view, MailService $mailService)
21
    {
22
        $this->view = $view;
23
        $this->mailService = $mailService;
24
    }
25
26
    /**
27
     * @param ServerRequestInterface $request
28
     * @param array $args
29
     * @return ResponseInterface $response
30
     * @throws \Exception
31
     */
32
    public function indexAction(ServerRequestInterface $request, array $args): ResponseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        $msg = new EmailMessage();
35
        $msg->setFrom('[email protected]');
36
        $msg->setTo('[email protected]');
37
        $msg->setSubject('Purest clickbait');
38
        $msg->setTemplate('testemails::hello');
39
        $msg->setViewData([
40
            'name' => 'John',
41
        ]);
42
43
        $this->mailService->sendEmail($msg);
44
        $body = $this->view->render('test::index', []);
45
46
        return new HtmlResponse($body);
47
    }
48
}
49