Code Duplication    Length = 26-28 lines in 3 locations

src/Place/Place.php 2 locations

@@ 267-294 (lines=28) @@
264
    /**
265
     * @param PlaceImportedFromUDB2 $placeImported
266
     */
267
    public function applyPlaceImportedFromUDB2(
268
        PlaceImportedFromUDB2 $placeImported
269
    ) {
270
        $this->placeId = $placeImported->getActorId();
271
272
        // When importing from UDB2 the default main language is always 'nl'.
273
        $this->mainLanguage = new Language('nl');
274
275
        $udb2Actor = ActorItemFactory::createActorFromCdbXml(
276
            $placeImported->getCdbXmlNamespaceUri(),
277
            $placeImported->getCdbXml()
278
        );
279
280
        // Just clear the facilities.
281
        $this->facilities = [];
282
283
        // Just clear the contact point.
284
        $this->contactPoint = null;
285
286
        // Just clear the calendar.
287
        $this->calendar = null;
288
289
        // Just clear typical age range.
290
        $this->typicalAgeRange = null;
291
292
        $this->importWorkflowStatus($udb2Actor);
293
        $this->labels = LabelCollection::fromKeywords($udb2Actor->getKeywords(true));
294
    }
295
296
    /**
297
     * @param PlaceUpdatedFromUDB2 $placeUpdatedFromUDB2
@@ 299-325 (lines=27) @@
296
    /**
297
     * @param PlaceUpdatedFromUDB2 $placeUpdatedFromUDB2
298
     */
299
    public function applyPlaceUpdatedFromUDB2(
300
        PlaceUpdatedFromUDB2 $placeUpdatedFromUDB2
301
    ) {
302
        // Note: when updating from UDB2 never change the main language.
303
304
        $udb2Actor = ActorItemFactory::createActorFromCdbXml(
305
            $placeUpdatedFromUDB2->getCdbXmlNamespaceUri(),
306
            $placeUpdatedFromUDB2->getCdbXml()
307
        );
308
309
        // Just clear the facilities.
310
        $this->facilities = [];
311
312
        // Just clear the contact point.
313
        $this->contactPoint = null;
314
315
        // Just clear the calendar.
316
        $this->calendar = null;
317
318
        // Just clear typical age range.
319
        $this->typicalAgeRange = null;
320
321
        $this->importWorkflowStatus($udb2Actor);
322
        $this->labels = LabelCollection::fromKeywords($udb2Actor->getKeywords(true));
323
324
        unset($this->addresses[$this->mainLanguage->getCode()]);
325
    }
326
327
    /**
328
     * @inheritdoc

src/Event/Event.php 1 location

@@ 242-267 (lines=26) @@
239
    /**
240
     * @param EventCdbXMLInterface $eventCdbXML
241
     */
242
    protected function setUDB2Data(
243
        EventCdbXMLInterface $eventCdbXML
244
    ) {
245
        $udb2Event = EventItemFactory::createEventFromCdbXml(
246
            $eventCdbXML->getCdbXmlNamespaceUri(),
247
            $eventCdbXML->getCdbXml()
248
        );
249
250
        // Just clear the facilities.
251
        $this->facilities = [];
252
253
        // Just clear the location id after an import or update.
254
        $this->locationId = null;
255
256
        // Just clear the contact point.
257
        $this->contactPoint = null;
258
259
        // Just clear the calendar.
260
        $this->calendar = null;
261
262
        // Just clear typical age range.
263
        $this->typicalAgeRange = null;
264
265
        $this->importWorkflowStatus($udb2Event);
266
        $this->labels = LabelCollection::fromKeywords($udb2Event->getKeywords(true));
267
    }
268
269
    /**
270
     * Update the major info.