Completed
Push — master ( d58309...398f96 )
by Sebastian
06:30 queued 02:44
created

ContentBlockRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 10 10 1
A failedValidation() 4 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\Requests\Back;
4
5
use App\Http\Requests\Request;
6
use Illuminate\Contracts\Validation\Validator;
7
8 View Code Duplication
class ContentBlockRequest extends Request
0 ignored issues
show
Duplication introduced by
This class 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...
9
{
10
    public function rules(): array
11
    {
12
        return [
13
            'model_name' => 'required',
14
            'model_id' => 'required',
15
            'collection_name' => 'required',
16
        ];
17
18
        return $rules;
0 ignored issues
show
Unused Code introduced by
return $rules; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
19
    }
20
21
    protected function failedValidation(Validator $validator)
22
    {
23
        return response()->json($validator->messages(), 400);
24
    }
25
}
26