Passed
Push — master ( a569b2...1b7ab6 )
by Christian
03:49
created

FindRole   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 15
c 1
b 1
f 0
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 23 2
1
<?php
2
3
namespace Omatech\Mage\Core\Repositories\Roles;
4
5
use Omatech\Mage\Core\Domains\Roles\Contracts\FindRoleInterface;
6
use Omatech\Mage\Core\Repositories\RoleBaseRepository;
7
8
class FindRole extends RoleBaseRepository implements FindRoleInterface
9
{
10 5
    public function find(int $id)
11
    {
12 5
        $role = $this->query()->find($id);
13
14 5
        if (null === $role) {
15 1
            return null;
16
        }
17
18
        $permissions = array_map(static function ($permission) {
19 1
            return app('mage.permissions')::find($permission['id']);
0 ignored issues
show
Bug introduced by
The method find() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            return app('mage.permissions')::/** @scrutinizer ignore-call */ find($permission['id']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20 4
        }, $role->permissions->toArray());
21
22 4
        $role = app('mage.roles')::fromArray([
0 ignored issues
show
Bug introduced by
The method fromArray() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $role = app('mage.roles')::/** @scrutinizer ignore-call */ fromArray([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23 4
            'id'         => $role->id,
24 4
            'name'       => $role->name,
25 4
            'guard_name' => $role->guard_name,
26 4
            'created_at' => $role->created_at,
27 4
            'updated_at' => $role->updated_at,
28
        ]);
29
30 4
        $role->assignPermissions($permissions);
31
32 4
        return $role;
33
    }
34
}
35