/**
  * {@inheritdoc}
  */
 public function getPoser($id)
 {
     $count = 'n/a';
     if ($downloads = $this->storage->fetch($id)) {
         $count = $this->normalizer->normalize($downloads);
     }
     return new PoserBadge('downloads', sprintf('%s last month', $count), '097ABB');
 }
Example #2
0
 /**
  * @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;
 }
Example #3
0
 /**
  * @param array $csvLines
  * @return string
  */
 private function formatDownloads(array $csvLines)
 {
     if (count($csvLines) < 2) {
         return 'n/a';
     }
     $downloads = explode(',', $csvLines[1]);
     if (count($downloads) < 2) {
         return 'n/a';
     }
     return $this->normalizer->normalize($downloads[1]);
 }