UserSerializer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 11 1
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\GraphQL\Serializers;
12
13
use App\Models\User;
14
use Illuminate\Database\Eloquent\Model;
15
16
/**
17
 * Class UserSerializer.
18
 */
19
class UserSerializer extends AbstractSerializer
20
{
21
    /**
22
     * @param  User|Model $user
23
     * @return array
24
     */
25
    public function toArray($user): array
26
    {
27
        return [
28
            'id'           => (int) $user->id,
29
            'name'         => $user->name,
30
            'email'        => $user->email,
31
            'avatar'       => $user->avatar,
32
            'token'        => $user->token,
33
            'is_confirmed' => $user->is_confirmed,
34
        ];
35
    }
36
}
37