Code Duplication    Length = 14-14 lines in 3 locations

src/EventListener/SerializerSubscriber.php 3 locations

@@ 56-69 (lines=14) @@
53
        $performanceEvent->setVenue($this->translator->trans($performanceEvent->getVenue()));
54
    }
55
56
    public function onPreEmployeeSerialize(ObjectEvent $event)
57
    {
58
        /** @var Employee $employee */
59
        $employee = $event->getObject();
60
61
        if ($employee->getAvatar()) {
62
            $avatarLinks = $this->mediaController->getMediumFormatsAction($employee->getAvatar()->getId());
63
            $employee->avatarThumbnails = $avatarLinks;
64
        }
65
66
        if ($galleryHasMediaLinks = $this->formatGalleries($employee->getGalleryHasMedia()->getValues(), $employee->getLocale())) {
67
            $employee->galleryHasMediaThumbnails = $galleryHasMediaLinks;
68
        }
69
    }
70
71
    public function onPrePerformanceSerialize(ObjectEvent $event)
72
    {
@@ 92-105 (lines=14) @@
89
        }
90
    }
91
92
    public function onPrePostSerialize(ObjectEvent $event)
93
    {
94
        /** @var Post $post */
95
        $post = $event->getObject();
96
97
        if ($post->getMainPicture()) {
98
            $mainImageLinks = $this->mediaController->getMediumFormatsAction($post->getMainPicture());
99
            $post->mainPictureThumbnails = $mainImageLinks;
100
        }
101
102
        if ($galleryHasMediaLinks = $this->formatGalleries($post->getGalleryHasMedia()->getValues(), $post->getLocale())) {
103
            $post->galleryHasMediaThumbnails = $galleryHasMediaLinks;
104
        }
105
    }
106
107
    public function onPreHistorySerialize(ObjectEvent $event)
108
    {
@@ 107-120 (lines=14) @@
104
        }
105
    }
106
107
    public function onPreHistorySerialize(ObjectEvent $event)
108
    {
109
        /** @var History $history */
110
        $history = $event->getObject();
111
112
        if ($history->getMainPicture()) {
113
            $mainImageLinks = $this->mediaController->getMediumFormatsAction($history->getMainPicture());
114
            $history->mainPictureThumbnails = $mainImageLinks;
115
        }
116
117
        if ($galleryHasMediaLinks = $this->formatGalleries($history->getGalleryHasMedia()->getValues(), $history->getLocale())) {
118
            $history->galleryHasMediaThumbnails = $galleryHasMediaLinks;
119
        }
120
    }
121
122
    protected function formatGalleries($galleries, $locale)
123
    {