LessonUpdateRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 93.75 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 1
dl 30
loc 32
rs 10
c 3
b 0
f 1
ccs 0
cts 17
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 8 8 2
A rules() 9 10 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 Scool\Timetables\Http\Requests;
4
5
use Auth;
6
use Illuminate\Foundation\Http\FormRequest;
7
8 View Code Duplication
class LessonUpdateRequest extends FormRequest
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
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        if (Auth::user()->can('edit lessons')) {
18
            return true;
19
        }
20
21
        return false;
22
    }
23
24
    /**
25
     * Get the validation rules that apply to the request.
26
     *
27
     * @return array
28
     */
29
    public function rules()
30
    {
31
        return [
32
            'user_id' => 'nullable|integer',
33
            'location_id' => 'nullable|integer',
34
            'day_id' => 'nullable|integer',
35
            'timeslot_id' => 'nullable|integer',
36
            'classroom_id' => 'nullable|integer',
37
        ];
38
    }
39
}
40