Completed
Pull Request — master (#238)
by Luc
09:35 queued 04:39
created

EventCommandHandler   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 194
Duplicated Lines 8.76 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 24
lcom 1
cbo 5
dl 17
loc 194
c 0
b 0
f 0
rs 10

24 Methods

Rating   Name   Duplication   Size   Complexity  
A handleUpdateMajorInfo() 17 17 1
A getAddLabelClassName() 0 4 1
A getDeleteLabelClassName() 0 4 1
A getAddImageClassName() 0 4 1
A getUpdateImageClassName() 0 4 1
A getRemoveImageClassName() 0 4 1
A getSelectMainImageClassName() 0 4 1
A getTranslateTitleClassName() 0 4 1
A getTranslateDescriptionClassName() 0 4 1
A getUpdateDescriptionClassName() 0 4 1
A getUpdateTypicalAgeRangeClassName() 0 4 1
A getDeleteTypicalAgeRangeClassName() 0 4 1
A getUpdateOrganizerClassName() 0 4 1
A getDeleteOrganizerClassName() 0 4 1
A getUpdateContactPointClassName() 0 4 1
A getUpdateBookingInfoClassName() 0 4 1
A getUpdatePriceInfoClassName() 0 4 1
A getDeleteOfferClassName() 0 4 1
A getPublishClassName() 0 4 1
A getApproveClassName() 0 4 1
A getRejectClassName() 0 4 1
A getFlagAsDuplicateClassName() 0 4 1
A getFlagAsInappropriateClassName() 0 4 1
A getSyncLabelsClassName() 0 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
4
namespace CultuurNet\UDB3\Event;
5
6
use CultuurNet\UDB3\Event\Commands\AddImage;
7
use CultuurNet\UDB3\Event\Commands\AddLabel;
8
use CultuurNet\UDB3\Event\Commands\DeleteEvent;
9
use CultuurNet\UDB3\Event\Commands\DeleteLabel;
10
use CultuurNet\UDB3\Event\Commands\Moderation\Approve;
11
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsDuplicate;
12
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsInappropriate;
13
use CultuurNet\UDB3\Event\Commands\Moderation\Publish;
14
use CultuurNet\UDB3\Event\Commands\Moderation\Reject;
15
use CultuurNet\UDB3\Event\Commands\RemoveImage;
16
use CultuurNet\UDB3\Event\Commands\DeleteOrganizer;
17
use CultuurNet\UDB3\Event\Commands\DeleteTypicalAgeRange;
18
use CultuurNet\UDB3\Event\Commands\SelectMainImage;
19
use CultuurNet\UDB3\Event\Commands\SyncLabels;
20
use CultuurNet\UDB3\Event\Commands\TranslateDescription;
21
use CultuurNet\UDB3\Event\Commands\TranslateTitle;
22
use CultuurNet\UDB3\Event\Commands\UpdateBookingInfo;
23
use CultuurNet\UDB3\Event\Commands\UpdateContactPoint;
24
use CultuurNet\UDB3\Event\Commands\UpdateDescription;
25
use CultuurNet\UDB3\Event\Commands\UpdateImage;
26
use CultuurNet\UDB3\Event\Commands\UpdateMajorInfo;
27
use CultuurNet\UDB3\Event\Commands\UpdateOrganizer;
28
use CultuurNet\UDB3\Event\Commands\UpdatePriceInfo;
29
use CultuurNet\UDB3\Event\Commands\UpdateTypicalAgeRange;
30
use CultuurNet\UDB3\Offer\OfferCommandHandler;
31
use Psr\Log\LoggerAwareInterface;
32
use Psr\Log\LoggerAwareTrait;
33
34
/**
35
 * Commandhandler for events
36
 */
37
class EventCommandHandler extends OfferCommandHandler implements LoggerAwareInterface
38
{
39
    use LoggerAwareTrait;
40
41
    /**
42
     * Handle an update the major info command.
43
     */
44 View Code Duplication
    public function handleUpdateMajorInfo(UpdateMajorInfo $updateMajorInfo)
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
47
        /** @var Event $event */
48
        $event = $this->offerRepository->load($updateMajorInfo->getItemId());
49
50
        $event->updateMajorInfo(
51
            $updateMajorInfo->getTitle(),
52
            $updateMajorInfo->getEventType(),
53
            $updateMajorInfo->getLocation(),
54
            $updateMajorInfo->getCalendar(),
55
            $updateMajorInfo->getTheme()
0 ignored issues
show
Bug introduced by
It seems like $updateMajorInfo->getTheme() targeting CultuurNet\UDB3\Event\Co...teMajorInfo::getTheme() can also be of type object<CultuurNet\UDB3\Theme>; however, CultuurNet\UDB3\Event\Event::updateMajorInfo() does only seem to accept object<CultuurNet\UDB3\Event\type>|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
56
        );
57
58
        $this->offerRepository->save($event);
59
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    protected function getAddLabelClassName()
66
    {
67
        return AddLabel::class;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    protected function getDeleteLabelClassName()
74
    {
75
        return DeleteLabel::class;
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81
    protected function getSyncLabelsClassName()
82
    {
83
        return SyncLabels::class;
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    protected function getAddImageClassName()
90
    {
91
        return AddImage::class;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    protected function getUpdateImageClassName()
98
    {
99
        return UpdateImage::class;
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    protected function getRemoveImageClassName()
106
    {
107
        return RemoveImage::class;
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    protected function getSelectMainImageClassName()
114
    {
115
        return SelectMainImage::class;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    protected function getTranslateTitleClassName()
122
    {
123
        return TranslateTitle::class;
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    protected function getTranslateDescriptionClassName()
130
    {
131
        return TranslateDescription::class;
132
    }
133
134
    /**
135
     * @return string
136
     */
137
    protected function getUpdateDescriptionClassName()
138
    {
139
        return UpdateDescription::class;
140
    }
141
142
    /**
143
     * @return string
144
     */
145
    protected function getUpdateTypicalAgeRangeClassName()
146
    {
147
        return UpdateTypicalAgeRange::class;
148
    }
149
150
    /**
151
     * @return string
152
     */
153
    protected function getDeleteTypicalAgeRangeClassName()
154
    {
155
        return DeleteTypicalAgeRange::class;
156
    }
157
158
    /**
159
     * @return string
160
     */
161
    protected function getUpdateOrganizerClassName()
162
    {
163
        return UpdateOrganizer::class;
164
    }
165
166
    /**
167
     * @return string
168
     */
169
    protected function getDeleteOrganizerClassName()
170
    {
171
        return DeleteOrganizer::class;
172
    }
173
174
    /**
175
     * @return string
176
     */
177
    protected function getUpdateContactPointClassName()
178
    {
179
        return UpdateContactPoint::class;
180
    }
181
182
    /**
183
     * @return string
184
     */
185
    protected function getUpdateBookingInfoClassName()
186
    {
187
        return UpdateBookingInfo::class;
188
    }
189
190
    /**
191
     * @return string
192
     */
193
    protected function getUpdatePriceInfoClassName()
194
    {
195
        return UpdatePriceInfo::class;
196
    }
197
198
    /**
199
     * @return string
200
     */
201
    protected function getDeleteOfferClassName()
202
    {
203
        return DeleteEvent::class;
204
    }
205
206
    protected function getPublishClassName()
207
    {
208
        return Publish::class;
209
    }
210
211
    protected function getApproveClassName()
212
    {
213
        return Approve::class;
214
    }
215
216
    protected function getRejectClassName()
217
    {
218
        return Reject::class;
219
    }
220
221
    protected function getFlagAsDuplicateClassName()
222
    {
223
        return FlagAsDuplicate::class;
224
    }
225
226
    protected function getFlagAsInappropriateClassName()
227
    {
228
        return FlagAsInappropriate::class;
229
    }
230
}
231