RoleTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
c 0
b 0
f 0
rs 9.9
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Containers\Authorization\UI\API\Transformers;
4
5
use App\Containers\Authorization\Models\Role;
6
use App\Ship\Parents\Transformers\Transformer;
7
8
/**
9
 * Class RoleTransformer.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class RoleTransformer extends Transformer
14
{
15
16
    protected $availableIncludes = [
17
18
    ];
19
20
    protected $defaultIncludes = [
21
        'permissions'
22
    ];
23
24
    /**
25
     * @param \App\Containers\Authorization\Models\Role $role
26
     *
27
     * @return array
28
     */
29 View Code Duplication
    public function transform(Role $role)
0 ignored issues
show
Duplication introduced by Mahmoud Zalt
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        return [
32
            'object'       => 'Role',
33
            'id'           => $role->getHashedKey(), // << Unique Identifier
34
            'name'         => $role->name, // << Unique Identifier
35
            'description'  => $role->description,
36
            'display_name' => $role->display_name,
37
            'level'        => $role->level,
38
        ];
39
    }
40
41
    /**
42
     * @param \App\Containers\Authorization\Models\Role $role
43
     *
44
     * @return  \League\Fractal\Resource\Collection
45
     */
46
    public function includePermissions(Role $role)
47
    {
48
        return $this->collection($role->permissions, new PermissionTransformer());
49
    }
50
51
}
52