Code Duplication    Length = 4-4 lines in 4 locations

src/PlaygroundGame/Service/Game.php 4 locations

@@ 100-103 (lines=4) @@
97
98
        // I must switch from original format to the Y-m-d format because
99
        // this is the only one accepted by new DateTime($value)
100
        if (isset($data['publicationDate']) && $data['publicationDate']) {
101
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['publicationDate']);
102
            $data['publicationDate'] = $tmpDate->format('Y-m-d');
103
        }
104
        if (isset($data['startDate']) && $data['startDate']) {
105
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['startDate']);
106
            $data['startDate'] = $tmpDate->format('Y-m-d');
@@ 104-107 (lines=4) @@
101
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['publicationDate']);
102
            $data['publicationDate'] = $tmpDate->format('Y-m-d');
103
        }
104
        if (isset($data['startDate']) && $data['startDate']) {
105
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['startDate']);
106
            $data['startDate'] = $tmpDate->format('Y-m-d');
107
        }
108
        if (isset($data['endDate']) && $data['endDate']) {
109
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['endDate']);
110
            $data['endDate'] = $tmpDate->format('Y-m-d');
@@ 108-111 (lines=4) @@
105
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['startDate']);
106
            $data['startDate'] = $tmpDate->format('Y-m-d');
107
        }
108
        if (isset($data['endDate']) && $data['endDate']) {
109
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['endDate']);
110
            $data['endDate'] = $tmpDate->format('Y-m-d');
111
        }
112
        if (isset($data['closeDate']) && $data['closeDate']) {
113
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['closeDate']);
114
            $data['closeDate'] = $tmpDate->format('Y-m-d');
@@ 112-115 (lines=4) @@
109
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['endDate']);
110
            $data['endDate'] = $tmpDate->format('Y-m-d');
111
        }
112
        if (isset($data['closeDate']) && $data['closeDate']) {
113
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['closeDate']);
114
            $data['closeDate'] = $tmpDate->format('Y-m-d');
115
        }
116
117
        // If publicationDate is null, I update it with the startDate if not null neither
118
        if ((! isset($data['publicationDate']) || $data['publicationDate'] == '') &&