Completed
Push — master ( d8e732...9dc7e5 )
by Manel
02:47
created

EnrollmentBrowseRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Scool\EnrollmentMobile\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
/**
8
 * Class EnrollmentCreateRequest
9
 * @package Scool\EnrollmentMobile\Http\Requests
10
 */
11
class EnrollmentBrowseRequest extends FormRequest
12
{
13
    /**
14
     * Determine if the user is authorized to make this request.
15
     *
16
     * @return bool
17
     */
18
    public function authorize()
19
    {
20
        return Auth::user()->can('show enrollments');
21
        //return false; //Per defecte
22
23
        //De moment true
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
//if (auth:user()->can('update enrollments')) {
25
        return true;
0 ignored issues
show
Unused Code introduced by
//return false; //Per de...ments')) { return true; 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...
26
        //}
27
        //return false;
28
        //TODO: crear requests de show, delete... crear permissos amb un seed. (create writter(BREAD(Browse,Read...)). Crear rol manage per donar-li tots els anteriors.
29
    }
30
31
32
33
    /**
34
     * Get the validation rules that apply to the request.
35
     *
36
     * @return array
37
     */
38
    public function rules()
39
    {
40
        return [
41
            'name' => 'required|min:5|max:30'
42
        ];
43
    }
44
}
45