Code Duplication    Length = 11-11 lines in 2 locations

src/Service/Game.php 1 location

@@ 727-737 (lines=11) @@
724
725
        foreach ($entries as $k => $entry) {
726
            $entryData = json_decode($entry['playerData'], true);
727
            foreach ($header as $key => $v) {
728
                if (isset($entryData[$key])) {
729
                    $results[$k][$key] = (is_array($entryData[$key]))?implode(', ', $entryData[$key]):$entryData[$key];
730
                } elseif (array_key_exists($key, $entry)) {
731
                    $results[$k][$key] = ($entry[$key] instanceof \DateTime)?
732
                        $entry[$key]->format('Y-m-d H:i:s'):
733
                        $entry[$key];
734
                } else {
735
                    $results[$k][$key] = '';
736
                }
737
            }
738
        }
739
740
        return $results;

src/Service/InstantWin.php 1 location

@@ 593-603 (lines=11) @@
590
            $entryData = json_decode($entry['playerData'], true);
591
            $winner = $entry['winner'];
592
593
            foreach ($header as $key => $v) {
594
                if (isset($entryData[$key]) && $key !=='id') {
595
                    $results[$k][$key] = (is_array($entryData[$key]))?implode(', ', $entryData[$key]):$entryData[$key];
596
                } elseif (array_key_exists($key, $entry)) {
597
                    $results[$k][$key] = ($entry[$key] instanceof \DateTime)?
598
                        $entry[$key]->format('Y-m-d'):
599
                        $entry[$key];
600
                } else {
601
                    $results[$k][$key] = '';
602
                }
603
            }
604
            // If the occurrenceType is code, this will be triggered for every entry. To be improved.
605
            if ($game->getOccurrenceType() === 'code' || ($game->getOccurrenceType() === 'datetime' && $winner)) {
606
                $entry = $this->getEntryMapper()->findById($entry['id']);