LocationTranslationMessage::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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