UserTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
dl 0
loc 26
rs 10
c 2
b 1
f 1
wmc 4
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A transformData() 0 16 4
1
<?php
2
3
namespace PHPHub\Transformers;
4
5
use PHPHub\User;
6
7
/**
8
 * Class UserTransformer.
9
 */
10
class UserTransformer extends BaseTransformer
11
{
12
    /**
13
     * Transform the \User entity.
14
     *
15
     * @param \User $model
16
     *
17
     * @return array
18
     */
19
    public function transformData($model)
20
    {
21
        $user = array_only($model->toArray(), User::$includable);
22
23
        if ($model->getAttribute('avatar')) {
24
            $user['avatar'] = starts_with($model->avatar, 'http') ? $model->avatar : cdn('uploads/avatars/'.$model->avatar);
25
        }
26
27
        if ($model->getAttribute('links')) {
28
            $user['links'] = [
29
                'replies_web_view' => route('users.replies.web_view', $model->id),
30
            ];
31
        }
32
33
        return $user;
34
    }
35
}
36