Completed
Push — master ( a0d489...a6481d )
by Fèvre
02:12
created

UserRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 1
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Facades\Request as FacadeRequest;
5
use Xetaravel\Models\User;
6
7
class UserRepository
8
{
9
    /**
10
     * Create a new user instance after a valid registration.
11
     *
12
     * @param array $data The data used to create the user.
13
     *
14
     * @return \Xetaravel\Models\User
15
     */
16
    public static function create(array $data): User
17
    {
18
        $ip = FacadeRequest::ip();
19
20
        return User::create([
21
            'username' => $data['username'],
22
            'email' => $data['email'],
23
            'password' => bcrypt($data['password']),
24
            'register_ip' => $ip,
25
            'last_login_ip' => $ip,
26
            'last_login' => new \DateTime()
27
        ]);
28
    }
29
}
30