public function processLogStats($collection)
    {
        $validLogs = $collection->filter(function ($line) {
            return $this->validateLine($line);
        });

        $sentBytes = $validLogs->pluck('sentBytes');

        $stats = [
            'hits' => $validLogs->count(),
            'total_data_sent' => $sentBytes->sum(),
            'most_common_method' => $this->sortByField('requestMethod', $validLogs),
            'most_common_url' => $this->sortByField('URL', $validLogs),
            'most_common_user_agent' => $this->sortByField('HeaderUserAgent', $validLogs),
        ];

        return $stats;
    }