DocsPageSerializer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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