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

FindOrFailPermission   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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