Passed
Push — master ( 342071...ce1cac )
by Christian
04:33
created

FindOrFailUser::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

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 5
cts 5
cp 1
crap 2
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 4
    public function __construct()
19
    {
20 4
        $this->find = app()->make(FindUser::class);
21 4
    }
22
23
    /**
24
     * @param int $id
25
     *
26
     * @throws UserDoesNotExistsException
27
     *
28
     * @return User
29
     */
30 4
    public function make(int $id): User
31
    {
32 4
        $user = $this->find->make($id);
33
34 4
        if (null === $user) {
35 1
            throw new UserDoesNotExistsException();
36
        }
37
38 3
        return $user;
39
    }
40
}
41