Completed
Pull Request — master (#17)
by Fèvre
02:48
created

PasswordResetValidator::validateEmail()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
namespace Xetaravel\Models\Validators;
3
4
use Illuminate\Support\Facades\App;
5
use Illuminate\Support\Facades\Validator as FacadeValidator;
6
use Illuminate\Validation\Validator;
7
8
class PasswordResetValidator
9
{
10
    /**
11
     * Validate the email for the given request.
12
     *
13
     * @param array $data The data to validate.
14
     *
15
     * @return \Illuminate\Validation\Validator
16
     */
17
    public static function validateEmail(array $data): Validator
18
    {
19
        $rules = [
20
            'email' => 'required|email'
21
        ];
22
23
        // Bipass the captcha for the unit testing.
24
        if (App::environment() !== 'testing') {
25
            $rules = array_merge($rules, ['g-recaptcha-response' => 'required|recaptcha']);
26
        }
27
28
        return FacadeValidator::make($data, $rules);
29
    }
30
}
31