public function take($limit) { if ($limit < 0) { return $this->slice($limit, abs($limit)); } return $this->slice(0, $limit); }
protected function summarizeTopBrowsers(Collection $topBrowsers, int $maxResults) : Collection { return $topBrowsers->take($maxResults - 1)->push(['browser' => 'Others', 'sessions' => $topBrowsers->splice($maxResults - 1)->sum('sessions')]); }