Code Duplication    Length = 4-4 lines in 4 locations

src/PlaygroundGame/Service/Game.php 4 locations

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