Code Duplication    Length = 87-87 lines in 2 locations

src/Message/Article/AbstractCategoryMessage.php 1 location

@@ 13-99 (lines=87) @@
10
/**
11
 * Class AbstractCategoryMessage
12
 */
13
abstract class AbstractCategoryMessage implements MessageInterface
14
{
15
    use SiteAwareMessageTrait;
16
17
    /**
18
     * @var int|null
19
     */
20
    private $parentRootId;
21
22
    /**
23
     * @var bool|null
24
     */
25
    private $enabled;
26
27
    /**
28
     * @var CategoryTranslationMessage[]
29
     */
30
    private $translations = [];
31
32
    /**
33
     * @return int|null
34
     */
35
    public function getParentRootId()
36
    {
37
        return $this->parentRootId;
38
    }
39
40
    /**
41
     * @param int|null $parentRootId
42
     */
43
    public function setParentRootId(int $parentRootId = null)
44
    {
45
        $this->parentRootId = $parentRootId;
46
    }
47
48
    /**
49
     * @return bool|null
50
     */
51
    public function isEnabled()
52
    {
53
        return $this->enabled;
54
    }
55
56
    /**
57
     * @param bool|null $enabled
58
     */
59
    public function setEnabled(bool $enabled = null)
60
    {
61
        $this->enabled = $enabled;
62
    }
63
64
    /**
65
     * @return CategoryTranslationMessage[]
66
     */
67
    public function getTranslations(): array
68
    {
69
        return $this->translations;
70
    }
71
72
    /**
73
     * @param CategoryTranslationMessage $translation
74
     */
75
    public function addTranslation(CategoryTranslationMessage $translation)
76
    {
77
        $this->translations[] = $translation;
78
    }
79
80
    /**
81
     * @param CategoryTranslationMessage $translation
82
     */
83
    public function removeTranslation(CategoryTranslationMessage $translation)
84
    {
85
        array_splice($this->translations, array_search($translation, $this->translations), 1);
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function build()
92
    {
93
        return [
94
            'parentRootId' => $this->getParentRootId(),
95
            'enabled'      => $this->isEnabled(),
96
            'translations' => Helper::buildMessages($this->getTranslations(), 'locale'),
97
        ];
98
    }
99
}
100

src/Message/Field/AbstractFieldMessage.php 1 location

@@ 13-99 (lines=87) @@
10
/**
11
 * Class AbstractFieldMessage
12
 */
13
abstract class AbstractFieldMessage implements MessageInterface
14
{
15
    use SiteAwareMessageTrait;
16
17
    /**
18
     * @var string
19
     */
20
    private $token;
21
22
    /**
23
     * @var string
24
     */
25
    private $description;
26
27
    /**
28
     * @var FieldTranslationMessage[]
29
     */
30
    private $translations = [];
31
32
    /**
33
     * @return string
34
     */
35
    public function getToken(): string
36
    {
37
        return $this->token;
38
    }
39
40
    /**
41
     * @param string $token
42
     */
43
    public function setToken(string $token)
44
    {
45
        $this->token = $token;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getDescription(): string
52
    {
53
        return $this->description;
54
    }
55
56
    /**
57
     * @param string $description
58
     */
59
    public function setDescription(string $description)
60
    {
61
        $this->description = $description;
62
    }
63
64
    /**
65
     * @return FieldTranslationMessage[]
66
     */
67
    public function getTranslations(): array
68
    {
69
        return $this->translations;
70
    }
71
72
    /**
73
     * @param FieldTranslationMessage $translation
74
     */
75
    public function addTranslation(FieldTranslationMessage $translation)
76
    {
77
        $this->translations[] = $translation;
78
    }
79
80
    /**
81
     * @param FieldTranslationMessage $translation
82
     */
83
    public function removeTranslation(FieldTranslationMessage $translation)
84
    {
85
        array_splice($this->translations, array_search($translation, $this->translations), 1);
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function build()
92
    {
93
        return [
94
            'token'        => $this->getToken(),
95
            'description'  => $this->getDescription(),
96
            'translations' => Helper::buildMessages($this->getTranslations(), 'locale'),
97
        ];
98
    }
99
}
100