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

TipSerializer::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
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