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

FindOrFailUser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A make() 0 9 2
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