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

UserConfirmationService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 21
ccs 8
cts 9
cp 0.8889
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 11 2
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\Event\UserEvent;
16
use Da\User\Model\User;
17
18
class UserConfirmationService implements ServiceInterface
19
{
20
    protected $model;
21
22 1
    public function __construct(User $model)
23
    {
24 1
        $this->model = $model;
25 1
    }
26
27 1
    public function run()
28
    {
29 1
        $this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION);
30 1
        if ((bool)$this->model->updateAttributes(['confirmed_at' => time()])) {
31 1
            $this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION);
32
33 1
            return true;
34
        }
35
36
        return false;
37
    }
38
}
39