Passed
Push — master ( 2c144a...cc2b65 )
by Christian
03:20
created

FindOrFailPermission::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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