Completed
Push — master ( 291557...80411a )
by wen
03:35
created

UpdatePermissionRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 24.44 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 1
dl 11
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 11 11 1
A getMessages() 0 8 1
A getAttributes() 0 6 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 Sco\Admin\Http\Requests;
4
5
use Illuminate\Contracts\Validation\Validator;
6
7
class UpdatePermissionRequest extends BaseFormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14
    public function authorize()
15
    {
16
        return true;
17
    }
18
19
    /**
20
     * Get the validation rules that apply to the request.
21
     *
22
     * @return array
23
     */
24 View Code Duplication
    public function rules()
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...
25
    {
26
        return [
27
            'id'           => 'integer',
28
            'pid'          => 'integer|different:id',
29
            'display_name' => 'required|max:50',
30
            'name'         => ['bail', 'required', 'regex:/^[\w\.#]+$/'],
31
            'is_menu'      => 'in:0,1',
32
            'sort'         => 'integer|between:0,255',
33
        ];
34
    }
35
36
    protected function getMessages()
37
    {
38
        return [
39
            'max'      => trans('admin::validation.max.numeric'),
40
            'between'  => trans('admin::validation.between.numeric'),
41
            'different' => '所属父级不能是自己',
42
        ];
43
    }
44
45
    protected function getAttributes()
46
    {
47
        return [
48
            'name' => '菜单名称',
49
        ];
50
    }
51
}
52