Passed
Push — master ( e5b31a...cf340d )
by Arthur
04:48
created

UserService::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 04.10.18
6
 * Time: 16:17.
7
 */
8
9
namespace Modules\User\Services;
10
11
use Modules\User\Contracts\UserServiceContract;
12
use Modules\User\Entities\User;
13
14
class UserService implements UserServiceContract
15
{
16
    public function find($id): ?User
17
    {
18
        return User::find($id);
19
    }
20
21
    public function update($id, $data): ?User
22
    {
23
        $user = $this->find($id);
24
        $user->update($data);
25
        return $user;
26
    }
27
28
    public function create($data): User
29
    {
30
        return User::create($data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Modules\User\Entities\User::create($data) could return the type Illuminate\Database\Eloquent\Model which includes types incompatible with the type-hinted return Modules\User\Entities\User. Consider adding an additional type-check to rule them out.
Loading history...
31
    }
32
33
    public function delete($id): bool
34
    {
35
        return User::destroy($id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Modules\User\Entities\User::destroy($id) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
36
    }
37
38
    public function newUser($data): User
39
    {
40
        return new User($data);
41
    }
42
43
44
}
45