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

FindOrFailUser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 30
ccs 7
cts 8
cp 0.875
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 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