Completed
Push — master ( e1cce4...d2c19b )
by David
09:34 queued 11s
created

UserSaveRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 7 1
A failedValidation() 0 4 1
1
<?php
2
3
namespace Torralbodavid\DuckFunkCore\Http\Request\Avatar;
4
5
use Illuminate\Contracts\Validation\Validator;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Validation\Rule;
8
use Torralbodavid\DuckFunkCore\Exceptions\Welcome\UserSave;
9
10
class UserSaveRequest extends FormRequest
11
{
12
    /**
13
     * Determine if the user is authorized to make this request.
14
     *
15
     * @return bool
16
     */
17
    public function authorize()
18
    {
19
        return true;
20
    }
21
22
    /**
23
     * Get the validation rules that apply to the request.
24
     * @return array
25
     */
26
    public function rules()
27
    {
28
        return [
29
            'figure' => ['required'],
30
            'gender' => ['required', 'max:1', Rule::in(['m', 'f'])],
31
        ];
32
    }
33
34
    protected function failedValidation(Validator $validator)
35
    {
36
        throw new UserSave($validator);
37
    }
38
}
39