Completed
Push — master ( 831b77...b56796 )
by Antonio
02:41
created

ResendConfirmationService::run()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 2
nop 0
crap 3
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-usuario project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\User\Service;
13
14
use Da\User\Contracts\ServiceInterface;
15
use Da\User\Factory\TokenFactory;
16
use Da\User\Model\User;
17
use yii\log\Logger;
18
19
class ResendConfirmationService implements ServiceInterface
20
{
21
    protected $model;
22
    protected $mailService;
23
    protected $logger;
24
25 1
    public function __construct(User $model, MailService $mailService, Logger $logger)
26
    {
27 1
        $this->model = $model;
28 1
        $this->mailService = $mailService;
29 1
        $this->logger = $logger;
30 1
    }
31
32 1
    public function run()
33
    {
34 1
        if ($this->model && !$this->model->getIsConfirmed()) {
35 1
            $token = TokenFactory::makeConfirmationToken($this->model->id);
36 1
            $this->mailService->setViewParam('token', $token);
37
38 1
            return $this->mailService->run();
39
        }
40
41 1
        return false;
42
    }
43
}
44