Completed
Pull Request — master (#251)
by
unknown
02:45
created

ResendConfirmationService::run()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
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 Da\User\Traits\MailAwareTrait;
18
19
class ResendConfirmationService implements ServiceInterface
20
{
21
    use MailAwareTrait;
22
23
    protected $model;
24
    protected $mailService;
25
26 1
    public function __construct(User $model, MailService $mailService)
27
    {
28 1
        $this->model = $model;
29 1
        $this->mailService = $mailService;
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->sendMail($this->model);
39
        }
40
41 1
        return false;
42
    }
43
}
44