RegistrationService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php namespace NukaCode\Users\Services;
2
3
use Illuminate\Auth\AuthManager;
4
use Illuminate\Config\Repository;
5
6
class RegistrationService {
7
8
    private $user;
9
10
    private $auth;
11
12
    private $config;
13
14
    public function __construct(\User $user, AuthManager $auth, Repository $config)
15
    {
16
        $this->user   = $user;
17
        $this->auth   = $auth;
18
        $this->config = $config;
19
    }
20
21
    public function register(array $user)
22
    {
23
        // Create the new user
24
        $result = $this->user->create($user);
25
26
        if ($result) {
27
            // Assign the guest role
28
            $this->user->addRole($this->config->get('users.main.guest'));
29
30
            // Log the user in
31
            $this->auth->login($this->user->getEntity());
32
        }
33
34
        return $result;
35
    }
36
}
37