private function dumpVersionToIndividualFile(Version $version, $file, $key) { $this->loadIndividualFile($file, $key); $data = $version->toArray(); $data['uid'] = $version->getId(); $this->individualFiles[$key]['packages'][strtolower($version->getName())][$version->getVersion()] = $data; $timestamp = $version->getReleasedAt() ? $version->getReleasedAt()->getTimestamp() : time(); if (!isset($this->individualFilesMtime[$key]) || $this->individualFilesMtime[$key] < $timestamp) { $this->individualFilesMtime[$key] = $timestamp; } }
private function createDatePoints(DateTimeImmutable $from, DateTimeImmutable $to, $average, Package $package, Version $version = null) { $interval = $this->getStatsInterval($average); $dateKey = $average === 'monthly' ? 'Ym' : 'Ymd'; $dateFormat = $average === 'monthly' ? 'Y-m' : 'Y-m-d'; $dateJump = $average === 'monthly' ? '+1month' : '+1day'; if ($average === 'monthly') { $to = new DateTimeImmutable('last day of ' . $to->format('Y-m')); } $nextDataPointLabel = $from->format($dateFormat); $nextDataPoint = $from->modify($interval); $datePoints = []; while ($from <= $to) { $datePoints[$nextDataPointLabel][] = 'dl:' . $package->getId() . ($version ? '-' . $version->getId() : '') . ':' . $from->format($dateKey); $from = $from->modify($dateJump); if ($from >= $nextDataPoint) { $nextDataPointLabel = $from->format($dateFormat); $nextDataPoint = $from->modify($interval); } } return $datePoints; }