Test Failed
Push — feature-laravel-5.4 ( d62334...6d0d6f )
by Kirill
04:24
created

TipSerializer   A

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
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace App\GraphQL\Serializers;
11
12
use App\Models\Tip;
13
use Illuminate\Database\Eloquent\Model;
14
15
/**
16
 * Class TipSerializer.
17
 */
18
class TipSerializer extends AbstractSerializer
19
{
20
    /**
21
     * @param  Tip|Model $tip
22
     * @return array
23
     */
24
    public function toArray(Model $tip): array
25
    {
26
        return [
27
            'id'             => $tip->id,
28
            'content'        => $tip->content_rendered,
29
            'content_source' => $tip->content_source,
30
            'user'           => $tip->user,
31
            'likes'          => $tip->likes->count(),
32
            'dislikes'       => $tip->dislikes->count(),
33
        ];
34
    }
35
}
36