Completed
Push — master ( 7d04c8...2a4aa6 )
by Jan
10:55
created

PasswordController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 44 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 22
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prePostEmail() 11 11 2
A prePostReset() 11 11 2
A __construct() 0 4 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 App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Foundation\Auth\ResetsPasswords;
7
use \Illuminate\Http\Request;
8
9
class PasswordController extends Controller
10
{
11
    /*
12
    |--------------------------------------------------------------------------
13
    | Password Reset Controller
14
    |--------------------------------------------------------------------------
15
    |
16
    | This controller is responsible for handling password reset requests
17
    | and uses a simple trait to include this behavior. You're free to
18
    | explore this trait and override any methods you wish to tweak.
19
    |
20
    */
21
22
    use ResetsPasswords;
23
24
    /**
25
     * Create a new password controller instance.
26
     *
27
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
28
     */
29
    public function __construct()
30
    {
31
        $this->middleware('guest');
32
    }
33
    
34 View Code Duplication
    public function prePostEmail(Request $request){
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...
35
        
36
        /**
37
         * Add recaptcha
38
         */
39
        if(env('RECAPTCHA_ENABLED') == 1){
40
            $this->validate($request, ['g-recaptcha-response' => 'required|recaptcha']);
41
        }
42
        
43
        return $this->postEmail($request);
0 ignored issues
show
Bug introduced by
The method postEmail() does not exist on App\Http\Controllers\Auth\PasswordController. Did you maybe mean prePostEmail()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
44
    }
45
    
46 View Code Duplication
    public function prePostReset(Request $request){
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...
47
        
48
        /**
49
         * Add recaptcha
50
         */
51
        if(env('RECAPTCHA_ENABLED') == 1){
52
            $this->validate($request, ['g-recaptcha-response' => 'required|recaptcha']);
53
        }
54
        
55
        return $this->postReset($request);
0 ignored issues
show
Bug introduced by
The method postReset() does not exist on App\Http\Controllers\Auth\PasswordController. Did you maybe mean prePostReset()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
56
    }
57
    
58
}
59