PermissionByAuthorizableRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A rules() 0 15 2
1
<?php
2
3
namespace BBSLab\NovaPermission\Http\Requests;
4
5
/**
6
 * Class PermissionByAuthorizableRequest.
7
 *
8
 * @property int $id
9
 * @property string $type
10
 */
11
class PermissionByAuthorizableRequest extends PermissionRequest
12
{
13
    /**
14
     * Get the validation rules that apply to the request.
15
     *
16
     * @return array
17
     */
18
    public function rules()
19
    {
20
        return array_merge(parent::rules(), [
21
            'id' => 'required',
22
            'type' => [
23
                'required',
24
                'string',
25
                function ($attribute, $value, $fail) {
26
                    if (! class_exists($value)) {
27
                        $fail($attribute.'is invalid');
28
                    }
29
                },
30
            ],
31
        ]);
32
    }
33
}
34