public function getAnalytics(AnalyticsOptions $options) { $cachingId = $options->uniqueCachingString(); if ($this->cache->contains($cachingId)) { return unserialize($this->cache->fetch($cachingId)); } $ga = new GApi($this->ga_email, $this->ga_password); $ga->requestReportData($this->ga_profile_id, $options->getDimensions(), $options->getMetrics(), $options->getSortMetric(), $options->getFilter(), $options->getStartDate(), $options->getEndDate(), $options->getStartIndex(), $options->getMaxResults()); $results = array('totals' => $ga->getVisits()); foreach ($ga->getResults() as $item) { $results[$options->getDimension()][(string) $item] = $item->getVisits(); } $this->cache->save($cachingId, serialize($results), 3600); return $results; }