RegistrationService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A register() 0 15 2
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