PostWithAuthorDto   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 95
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 95
loc 95
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 17 17 1
A getId() 4 4 1
A getTitle() 4 4 1
A getSlug() 4 4 1
A getAuthorId() 4 4 1
A getAuthorMobile() 4 4 1
A getAuthorFullName() 4 4 1
A getAuthorEmail() 4 4 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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Explicit Architecture POC,
7
 * which is created on top of the Symfony Demo application.
8
 *
9
 * (c) Herberto Graça <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Acme\App\Core\Component\Blog\Application\Query;
16
17
use Acme\App\Core\Component\Blog\Domain\Post\PostId;
18
use Acme\App\Core\SharedKernel\Component\User\Domain\User\UserId;
19
use Acme\PhpExtension\ConstructableFromArrayInterface;
20
use Acme\PhpExtension\ConstructableFromArrayTrait;
21
22
/**
23
 * This is just a DTO, it only has getters, theres no logic to test, so we ignore it for code coverage purposes.
24
 *
25
 * @codeCoverageIgnore
26
 */
27 View Code Duplication
final class PostWithAuthorDto implements ConstructableFromArrayInterface
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...
28
{
29
    use ConstructableFromArrayTrait;
30
31
    /**
32
     * @var string
33
     */
34
    private $title;
35
36
    /**
37
     * @var string
38
     */
39
    private $slug;
40
41
    /**
42
     * @var UserId
43
     */
44
    private $authorId;
45
46
    /**
47
     * @var string
48
     */
49
    private $authorMobile;
50
51
    /**
52
     * @var string
53
     */
54
    private $authorFullName;
55
56
    /**
57
     * @var string
58
     */
59
    private $authorEmail;
60
61
    /**
62
     * @var PostId
63
     */
64
    private $id;
65
66
    /**
67
     * @throws \Exception
68
     */
69
    public function __construct(
70
        PostId $id,
71
        string $title,
72
        string $slug,
73
        UserId $authorId,
74
        string $authorMobile,
75
        string $authorFullName,
76
        string $authorEmail
77
    ) {
78
        $this->id = $id;
79
        $this->title = $title;
80
        $this->slug = $slug;
81
        $this->authorId = $authorId;
82
        $this->authorMobile = $authorMobile;
83
        $this->authorFullName = $authorFullName;
84
        $this->authorEmail = $authorEmail;
85
    }
86
87
    public function getId(): PostId
88
    {
89
        return $this->id;
90
    }
91
92
    public function getTitle(): string
93
    {
94
        return $this->title;
95
    }
96
97
    public function getSlug(): string
98
    {
99
        return $this->slug;
100
    }
101
102
    public function getAuthorId(): UserId
103
    {
104
        return $this->authorId;
105
    }
106
107
    public function getAuthorMobile(): string
108
    {
109
        return $this->authorMobile;
110
    }
111
112
    public function getAuthorFullName(): string
113
    {
114
        return $this->authorFullName;
115
    }
116
117
    public function getAuthorEmail(): string
118
    {
119
        return $this->authorEmail;
120
    }
121
}
122