CreateNewUser::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 12
ccs 0
cts 9
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace App\Actions\Fortify;
4
5
use App\Models\User;
6
use Illuminate\Support\Facades\Hash;
7
use Illuminate\Support\Facades\Validator;
8
use Laravel\Fortify\Contracts\CreatesNewUsers;
9
10
class CreateNewUser implements CreatesNewUsers
11
{
12
    use PasswordValidationRules;
13
14
    /**
15
     * Validate and create a newly registered user.
16
     *
17
     * @param  array  $input
18
     * @return \App\Models\User
19
     */
20
    public function create(array $input)
21
    {
22
        Validator::make($input, [
23
            'name' => ['required', 'string', 'max:255'],
24
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
25
            'password' => $this->passwordRules(),
26
        ])->validate();
27
28
        return User::create([
29
            'name' => $input['name'],
30
            'email' => $input['email'],
31
            'password' => Hash::make($input['password']),
32
        ]);
33
    }
34
}
35