Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — development ( 9c55bd...0f1776 )
by José
03:28 queued 41s
created

RegisterController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 17.14 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 12
loc 70
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 1
A __construct() 0 4 1
A validator() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace DoeSangue\Http\Controllers\Auth;
4
5
use DoeSangue\Http\Controllers\Controller;
6
use Illuminate\Support\Facades\Validator;
7
use Illuminate\Foundation\Auth\RegistersUsers;
8
use DoeSangue\Models\User;
9
10
class RegisterController extends Controller
11
{
12
    /*
13
    |--------------------------------------------------------------------------
14
    | Register Controller
15
    |--------------------------------------------------------------------------
16
    |
17
    | This controller handles the registration of new users as well as their
18
    | validation and creation. By default this controller uses a trait to
19
    | provide this functionality without requiring any additional code.
20
    |
21
    */
22
23
    use RegistersUsers;
24
25
    /**
26
     * Where to redirect users after login / registration.
27
     *
28
     * @var string
29
     */
30
    protected $redirectTo = '/';
31
32
    /**
33
     * Create a new controller instance.
34
     */
35
    public function __construct()
36
    {
37
        $this->middleware('guest');
38
    }
39
40
    /**
41
     * Get a validator for an incoming registration request.
42
     *
43
     * @param array $data
44
     *
45
     * @return \Illuminate\Contracts\Validation\Validator
46
     */
47 View Code Duplication
    protected function validator(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        return Validator::make(
50
            $data, [
51
            'name' => 'required|max:255',
52
            'phone' => 'required|max:20|unique:users',
53
            'email' => 'required|email|max:255|unique:users',
54
            'username' => 'required|max:20',
55
            'password' => 'required|min:8|confirmed',
56
            ]
57
        );
58
    }
59
60
    /**
61
     * Create a new user instance after a valid registration.
62
     *
63
     * @param array $data
64
     *
65
     * @return User
66
     */
67
    protected function create(array $data)
68
    {
69
        return User::create(
70
            [
71
            'name' => $data[ 'name' ],
72
            'phone' => $data[ 'phone' ],
73
            'email' => $data[ 'email' ],
74
            'username' => $data[ 'username' ],
75
            'password' => bcrypt($data[ 'password' ]),
76
            ]
77
        );
78
    }
79
}
80