/** * @param string $id * @return null|string */ private function getDownloads($id) { if ($downloads = $this->parser->filter('plugin/' . $id, '.plugin-info__downloads')) { // "4 645" $downloads = str_replace(' ', '', trim($downloads)); $this->dispatcher->dispatch(espendIdeaBadgeEvents::DOWNLOADS_FETCHED, new PluginDownloadsFetchedEvent($id, $downloads)); return $this->normalizer->normalize($downloads); } return null; }
/** * {@inheritdoc} */ public function getPoser($id) { if (!($json = json_decode($this->parser->get('plugin/updates?pluginId=' . $id . '&start=0&size=1'), true))) { return $this->createBadge('n/a'); } if (!isset($json['updates'][0]['updateVersion'])) { return $this->createBadge('n/a'); } return $this->createBadge($json['updates'][0]['updateVersion']); }
/** * {@inheritdoc} */ public function getPoser($id) { $content = explode("\n", $this->parser->get('downloadStatistic/csv?pluginId=' . $id . '&updateId=&period=month')); return new PoserBadge('downloads', sprintf('%s last month', $this->formatDownloads($content)), '097ABB'); }