Completed
Push — master ( 5ee4c9...308b6a )
by Antonio
05:05
created

ResendConfirmationService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 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 yii\log\Logger;
18
19
class ResendConfirmationService implements ServiceInterface
20
{
21
    protected $model;
22
    protected $mailService;
23
    protected $logger;
24
25
    public function __construct(User $model, MailService $mailService, Logger $logger)
26
    {
27
        $this->model = $model;
28
        $this->mailService = $mailService;
29
        $this->logger = $logger;
30
    }
31
32
    public function run()
33
    {
34
        if ($this->model && !$this->model->getIsConfirmed()) {
35
            $token = TokenFactory::makeConfirmationToken($this->model->id);
36
            $this->mailService->setViewParam('token', $token);
37
38
            return $this->mailService->run();
39
        }
40
41
        return false;
42
    }
43
}
44