Code Duplication    Length = 13-14 lines in 2 locations

api/Lib/DsManager/Models/Orm/Player.php 1 location

@@ 103-115 (lines=13) @@
100
    /**
101
     * @return array
102
     */
103
    public static function getBest()
104
    {
105
        $result = MatchPlayer::selectRaw(
106
            'player_id, COUNT(*) as appearances , AVG(vote) avg, SUM(goals) goals'
107
        )->where('goals', '>', 0)
108
            ->orderByRaw('SUM(goals) DESC,COUNT(*) DESC')
109
            ->groupBy('player_id')->take(self::PLAYER_STATS_LIMIT)->get()->keyBy('player_id')->toArray();
110
        $players = Player::with('team')->whereIn('id', array_keys($result))->get()->toArray();
111
        $result = array_map(function ($player) use ($result) {
112
            return array_merge($player,$result[$player['id']]);
113
        }, $players);
114
        return $result;
115
    }
116
}

api/Lib/DsManager/Models/Orm/Team.php 1 location

@@ 130-143 (lines=14) @@
127
    /**
128
     * @return array
129
     */
130
    public static function getBest()
131
    {
132
        $result = Match::selectRaw('winner_id, COUNT(*) as won')
133
            ->whereNotNull('winner_id')->where('winner_id', '!=', 0)
134
            ->orderByRaw('COUNT(*) DESC')->groupBy('winner_id')
135
            ->take(self::TEAM_STATS_LIMIT)->get()->keyBy('winner_id')->toArray();
136
        $teams = Team::whereIn('id', array_keys($result))->get()->toArray();
137
        $result = array_map(function ($team) use ($result) {
138
            return array_merge($team, $result[$team['id']]);
139
140
        }, $teams);
141
142
        return $result;
143
    }
144
145
}