AuthController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 55
rs 10
wmc 3
lcom 0
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validator() 0 8 1
A create() 0 8 1
1
<?php
2
3
namespace PHPHub\Http\Controllers\Auth;
4
5
use PHPHub\User;
6
use Validator;
7
use PHPHub\Http\Controllers\Controller;
8
use Illuminate\Foundation\Auth\ThrottlesLogins;
9
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
10
11
class AuthController extends Controller
12
{
13
    /*
14
    |--------------------------------------------------------------------------
15
    | Registration & Login Controller
16
    |--------------------------------------------------------------------------
17
    |
18
    | This controller handles the registration of new users, as well as the
19
    | authentication of existing users. By default, this controller uses
20
    | a simple trait to add these behaviors. Why don't you explore it?
21
    |
22
    */
23
24
    use AuthenticatesAndRegistersUsers, ThrottlesLogins;
25
26
    /**
27
     * Create a new authentication controller instance.
28
     */
29
    public function __construct()
30
    {
31
        $this->middleware('guest', ['except' => 'getLogout']);
32
    }
33
34
    /**
35
     * Get a validator for an incoming registration request.
36
     *
37
     * @param array $data
38
     *
39
     * @return \Illuminate\Contracts\Validation\Validator
40
     */
41
    protected function validator(array $data)
42
    {
43
        return Validator::make($data, [
44
            'name'     => 'required|max:255',
45
            'email'    => 'required|email|max:255|unique:users',
46
            'password' => 'required|confirmed|min:6',
47
        ]);
48
    }
49
50
    /**
51
     * Create a new user instance after a valid registration.
52
     *
53
     * @param array $data
54
     *
55
     * @return User
56
     */
57
    protected function create(array $data)
58
    {
59
        return User::create([
60
            'name'     => $data['name'],
61
            'email'    => $data['email'],
62
            'password' => bcrypt($data['password']),
63
        ]);
64
    }
65
}
66