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

ResendConfirmationService::run()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 9.4285
cc 3
eloc 6
nc 2
nop 0
crap 12
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