We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
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) |
|
|
|||
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) |
||
79 | } |
||
80 |
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.