Test Failed
Push — master ( 5ef3bf...0f5f8c )
by Christian
03:06
created

FindOrFailPermission   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 11
cp 0
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\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
    public function __construct()
18
    {
19
        $this->find = app()->make(FindPermission::class);
20
    }
21
22
    /**
23
     * @param int $id
24
     * @return Permission
25
     * @throws PermissionDoesNotExistsException
26
     */
27
    public function make(int $id): Permission
28
    {
29
        $permission = $this->find->make($id);
30
31
        if ($permission === null) {
32
            throw new PermissionDoesNotExistsException;
33
        }
34
35
        return $permission;
36
    }
37
}
38