DocsPageSerializer::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 12
loc 12
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\Models\Docs;
12
use App\Models\DocsPage;
13
use Illuminate\Database\Eloquent\Model;
14
15
/**
16
 * Class DocsSerializer.
17
 */
18 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...
19
{
20
    /**
21
     * @param  Model|DocsPage $page
22
     * @return array
23
     */
24
    public function toArray($page): array
25
    {
26
        return [
27
            'id'             => $page->id,
28
            'title'          => trim($page->title),
29
            'slug'           => trim($page->slug),
30
            'content'        => $page->content_rendered,
31
            'content_source' => $page->content_source,
32
            'created_at'     => $this->formatDateTime($page->created_at),
33
            'updated_at'     => $this->formatDateTime($page->updated_at),
34
        ];
35
    }
36
}
37