ScannerStartRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Contracts\Validation\Validator;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Http\Exceptions\HttpResponseException;
8
9
class ScannerStartRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize()
17
    {
18
        // TODO: Check if thoken is authorized and have enough Credits.
19
        return true;
20
    }
21
22
    protected function failedValidation(Validator $validator)
23
    {
24
        throw new HttpResponseException(response()->json($validator->errors(), 422));
25
    }
26
27
    /**
28
     * Get the validation rules that apply to the request.
29
     *
30
     * @return array
31
     */
32
    public function rules()
33
    {
34
        return [
35
            'domain'         => 'required|url',
36
            'dangerLevel'    => 'integer|min:0|max:10',
37
            'callbackurls'   => 'array',
38
            'callbackurls.*' => 'url',
39
        ];
40
    }
41
}
42