Test Failed
Push — feature-laravel-5.4 ( 556e60...89a18e )
by Kirill
03:48
created

DocsPageSerializer::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace App\GraphQL\Serializers;
10
11
use App\GraphQL\Types\DocsPageType;
12
use App\Models\Docs;
13
use App\Models\DocsPage;
14
use Illuminate\Database\Eloquent\Model;
15
16
/**
17
 * Class DocsSerializer
18
 * @package App\GraphQL\Serializers
19
 */
20 View Code Duplication
class DocsPageSerializer extends AbstractSerializer
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @param Model|DocsPage $page
24
     * @return array
25
     */
26
    public function toArray(Model $page): array
27
    {
28
        return [
29
            'id'             => $page->id,
30
            'title'          => $page->title,
31
            'url'            => route('docs.show', [
32
                'version' => $page->docs->version,
33
                'slug'    => $page->slug,
34
            ]),
35
            'content'        => $page->content_rendered,
36
            'content_source' => $page->content_source,
37
            'created_at'     => $this->formatDateTime($page->created_at),
38
            'updated_at'     => $this->formatDateTime($page->updated_at),
39
        ];
40
    }
41
}