Code Duplication    Length = 61-61 lines in 2 locations

app/Containers/User/UI/API/Transformers/UserPrivateProfileTransformer.php 1 location

@@ 14-74 (lines=61) @@
11
 *
12
 * @author Johannes Schobel <[email protected]>
13
 */
14
class UserPrivateProfileTransformer extends Transformer
15
{
16
17
    /**
18
     * @var  array
19
     */
20
    protected $availableIncludes = [
21
        'roles',
22
    ];
23
24
    /**
25
     * @var  array
26
     */
27
    protected $defaultIncludes = [
28
29
    ];
30
31
    /**
32
     * @param \App\Containers\User\Models\User $user
33
     *
34
     * @return array
35
     */
36
    public function transform(User $user)
37
    {
38
        $response = [
39
            'object'               => 'User',
40
            'id'                   => $user->getHashedKey(),
41
            'name'                 => $user->name,
42
            'email'                => $user->email,
43
            'confirmed'            => $user->confirmed,
44
            'nickname'             => $user->nickname,
45
            'gender'               => $user->gender,
46
            'birth'                => $user->birth,
47
48
            'social_auth_provider' => $user->social_provider,
49
            'social_id'            => $user->social_id,
50
            'social_avatar'        => [
51
                'avatar'   => $user->social_avatar,
52
                'original' => $user->social_avatar_original,
53
            ],
54
55
            'created_at'           => $user->created_at,
56
            'updated_at'           => $user->updated_at,
57
            'readable_created_at'  => $user->created_at->diffForHumans(),
58
            'readable_updated_at'  => $user->updated_at->diffForHumans(),
59
        ];
60
61
        $response = $this->ifAdmin([
62
            'real_id'    => $user->id,
63
            'deleted_at' => $user->deleted_at,
64
        ], $response);
65
66
        return $response;
67
    }
68
69
    public function includeRoles(User $user)
70
    {
71
        return $this->collection($user->roles, new RoleTransformer());
72
    }
73
74
}
75

app/Containers/User/UI/API/Transformers/UserTransformer.php 1 location

@@ 14-74 (lines=61) @@
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class UserTransformer extends Transformer
15
{
16
17
    /**
18
     * @var  array
19
     */
20
    protected $availableIncludes = [
21
        'roles',
22
    ];
23
24
    /**
25
     * @var  array
26
     */
27
    protected $defaultIncludes = [
28
29
    ];
30
31
    /**
32
     * @param \App\Containers\User\Models\User $user
33
     *
34
     * @return array
35
     */
36
    public function transform(User $user)
37
    {
38
        $response = [
39
            'object'               => 'User',
40
            'id'                   => $user->getHashedKey(),
41
            'name'                 => $user->name,
42
            'email'                => $user->email,
43
            'confirmed'            => $user->confirmed,
44
            'nickname'             => $user->nickname,
45
            'gender'               => $user->gender,
46
            'birth'                => $user->birth,
47
48
            'social_auth_provider' => $user->social_provider,
49
            'social_id'            => $user->social_id,
50
            'social_avatar'        => [
51
                'avatar'   => $user->social_avatar,
52
                'original' => $user->social_avatar_original,
53
            ],
54
55
            'created_at'           => $user->created_at,
56
            'updated_at'           => $user->updated_at,
57
            'readable_created_at'  => $user->created_at->diffForHumans(),
58
            'readable_updated_at'  => $user->updated_at->diffForHumans(),
59
        ];
60
61
        $response = $this->ifAdmin([
62
            'real_id'    => $user->id,
63
            'deleted_at' => $user->deleted_at,
64
        ], $response);
65
66
        return $response;
67
    }
68
69
    public function includeRoles(User $user)
70
    {
71
        return $this->collection($user->roles, new RoleTransformer());
72
    }
73
74
}
75