ContactMessageRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 16 2
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 ContactMessageRequest.
10
 *
11
 * @package Finder\Http\Requests
12
 */
13
class ContactMessageRequest 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', 'email', 'max:255'],
34
            'name' => ['required', 'string', 'max:255'],
35
            'subject' => ['required', 'string', 'max:255'],
36
            'message' => ['required', 'string', 'max:65535'],
37
        ];
38
39
        $reCaptchaRule = $this->container->make(ReCaptchaRule::class);
40
        if ($reCaptchaRule->isEnabled()) {
41
            $rules['g_recaptcha_response'] = ['required', $reCaptchaRule];
42
        }
43
44
        return $rules;
45
    }
46
}
47