LocationTranslationMessage   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 72
loc 72
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromLocationTranslation() 9 9 1
A getTitle() 4 4 1
A setTitle() 4 4 1
A getOpeningHours() 4 4 1
A setOpeningHours() 4 4 1
A build() 7 7 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
declare(strict_types=1);
3
4
namespace Yproximite\Api\Message\Location;
5
6
use Yproximite\Api\Message\MessageInterface;
7
use Yproximite\Api\Message\LocaleAwareMessageTrait;
8
use Yproximite\Api\Model\Location\LocationTranslation;
9
10
/**
11
 * Class LocationTranslationMessage
12
 */
13 View Code Duplication
class LocationTranslationMessage implements MessageInterface
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...
14
{
15
    use LocaleAwareMessageTrait;
16
17
    /**
18
     * @var string
19
     */
20
    private $title;
21
22
    /**
23
     * @var string|null
24
     */
25
    private $openingHours;
26
27
    /**
28
     * @param LocationTranslation $translation
29
     *
30
     * @return self
31
     */
32
    public static function createFromLocationTranslation(LocationTranslation $translation): self
33
    {
34
        $message = new self();
35
        $message->setLocale($translation->getLocale());
36
        $message->setTitle($translation->getTitle());
37
        $message->setOpeningHours($translation->getOpeningHours());
38
39
        return $message;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getTitle(): string
46
    {
47
        return $this->title;
48
    }
49
50
    /**
51
     * @param string $title
52
     */
53
    public function setTitle(string $title)
54
    {
55
        $this->title = $title;
56
    }
57
58
    /**
59
     * @return null|string
60
     */
61
    public function getOpeningHours()
62
    {
63
        return $this->openingHours;
64
    }
65
66
    /**
67
     * @param null|string $openingHours
68
     */
69
    public function setOpeningHours($openingHours)
70
    {
71
        $this->openingHours = $openingHours;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function build()
78
    {
79
        return [
80
            'title'        => $this->getTitle(),
81
            'openingHours' => $this->getOpeningHours(),
82
        ];
83
    }
84
}
85