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

ResendConfirmationService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 11 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