CreateAuthRequest::rules()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Finder\Http\Requests;
4
5
use Finder\Http\Rules\ReCaptchaRule;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
/**
9
 * Class CreateAuthRequest.
10
 *
11
 * @package Finder\Http\Requests
12
 */
13
class CreateAuthRequest extends FormRequest
14
{
15
    /**
16
     * Determine if the user is authorized to make this request.
17
     *
18
     * @return bool
19
     */
20
    public function authorize()
21
    {
22
        return true;
23
    }
24
25
    /**
26
     * Get the validation rules that apply to the request.
27
     *
28
     * @return array
29
     */
30
    public function rules()
31
    {
32
        $rules = [
33
            'email' => ['required', 'string', 'email'],
34
            'password' => ['required', 'string'],
35
        ];
36
37
        $reCaptchaRule = $this->container->make(ReCaptchaRule::class);
38
        if ($reCaptchaRule->isEnabled()) {
39
            $rules['g_recaptcha_response'] = ['required', $reCaptchaRule];
40
        }
41
42
        return $rules;
43
    }
44
}
45