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

UserConfirmationService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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