Test Failed
Push — master ( da5def...342071 )
by Christian
04:54
created

FindOrFailUser::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
1
<?php
2
3
namespace Omatech\Mage\Core\Domains\Users\Features;
4
5
use Omatech\Mage\Core\Domains\Users\Exceptions\UserDoesNotExistsException;
6
use Omatech\Mage\Core\Domains\Users\Jobs\FindUser;
7
use Omatech\Mage\Core\Domains\Users\User;
8
9
class FindOrFailUser
10
{
11
    private $find;
12
13
    /**
14
     * FindOrFailUser constructor.
15
     *
16
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
17
     */
18 1
    public function __construct()
19
    {
20 1
        $this->find = app()->make(FindUser::class);
21 1
    }
22
23
    /**
24
     * @param int $id
25
     *
26
     * @throws UserDoesNotExistsException
27
     *
28
     * @return User
29
     */
30 1
    public function make(int $id): User
31
    {
32 1
        $user = $this->find->make($id);
33
34 1
        if (null === $user) {
35 1
            throw new UserDoesNotExistsException();
36
        }
37
38
        return $user;
39
    }
40
}
41