setNbFollowers() public méthode

Set followers
public setNbFollowers ( integer $nbFollowers )
$nbFollowers integer
Exemple #1
0
 /**
  * Return true if the Repo exists on GitHub, false otherwise
  *
  * @param Entity\Bundle $bundle
  * @param array $data
  * @return boolean whether the Repo exists on GitHub
  */
 public function updateInfos(Entity\Bundle $bundle)
 {
     $this->output->write(' infos');
     try {
         $data = $this->github->getRepoApi()->show($bundle->getUsername(), $bundle->getName());
     } catch (\Github_HttpClient_Exception $e) {
         if (404 == $e->getCode()) {
             return false;
         }
         throw $e;
     }
     if ($data['fork']) {
         if ($data['watchers'] >= 10) {
             // Let's try to keep a forked repo with lots of watchers
         } else {
             return false;
         }
     }
     $bundle->setDescription(empty($data['description']) ? null : $data['description']);
     $bundle->setNbFollowers($data['watchers']);
     $bundle->setNbForks($data['forks']);
     $bundle->setCreatedAt(new \DateTime($data['created_at']));
     $bundle->setHomepage(empty($data['homepage']) ? null : $data['homepage']);
     return $bundle;
 }
 public function testGlobalScore()
 {
     $dispatcher = new EventDispatcher();
     $testers = array('Activity', 'Composer', 'Followers', 'KnpBundles', 'Readme', 'Travis');
     foreach ($testers as $testerClass) {
         $fqcn = sprintf('\\Knp\\Bundle\\KnpBundlesBundle\\EventListener\\Scoring\\%sListener', $testerClass);
         $tester = new $fqcn();
         $dispatcher->addListener(BundleEvent::UPDATE_SCORE, array($tester, 'onScoreUpdate'));
     }
     $bundle = new Bundle();
     // activity (+4)
     $bundle->setLastCommitAt(new \DateTime('-10days'));
     // composer (+5)
     $bundle->setComposerName('bundle-composer-name');
     // followers (+10)
     $bundle->setNbFollowers(10);
     // recommendation (+5)
     $bundle->addRecommender(new Developer());
     // readme (+5)
     $bundle->setReadme(str_repeat('-', 500));
     // travis (+10)
     $bundle->setUsesTravisCi(true);
     $bundle->setTravisCiBuildStatus(true);
     $dispatcher->dispatch(BundleEvent::UPDATE_SCORE, new BundleEvent($bundle));
     $bundle->recalculateScore();
     $this->assertEquals(39, $bundle->getScore());
 }
 /**
  * @dataProvider provideFollowers
  */
 public function testFollowersScoreDetail($followers)
 {
     $bundle = new Bundle();
     $bundle->setNbFollowers($followers);
     $tester = new FollowersListener();
     $tester->updateScore($bundle);
     $bundle->recalculateScore();
     // 1 follower = 1 point
     $this->assertEquals($followers, $bundle->getScore());
 }
Exemple #4
0
 /**
  * @test
  */
 public function shouldNotHaveChangesWithOnlyChangedScore()
 {
     $bundle = new Bundle('knplabs/KnpMenuBundle');
     $bundle->setScore(1000);
     $bundle->setReadme('readme number one');
     $bundle->setLastCommitAt(new \DateTime('-10 day'));
     $bundle->setNbFollowers(100);
     $bundle->setNbForks(10);
     $beforeChange = $bundle->getStatusHash();
     $bundle->setScore(1100);
     $afterChange = $bundle->getStatusHash();
     $this->assertEquals($beforeChange, $afterChange);
 }
Exemple #5
0
 /**
  * Return true if the Repo exists on GitHub, false otherwise
  *
  * @param Bundle $bundle
  *
  * @return boolean whether the Repo exists on GitHub
  */
 public function updateInfos(Bundle $bundle)
 {
     $this->output->write(' infos');
     try {
         $data = $this->github->api('repo')->show($bundle->getOwnerName(), $bundle->getName());
     } catch (RuntimeException $e) {
         return false;
     }
     // Let's try to only keep a forked repo with lots of watchers
     if ($data['fork'] && $data['watchers'] < 10) {
         return false;
     }
     $bundle->setDescription(empty($data['description']) ? null : $data['description']);
     $bundle->setNbFollowers($data['watchers']);
     $bundle->setNbForks($data['forks']);
     $bundle->setIsFork($data['fork']);
     $bundle->setCreatedAt(new \DateTime($data['created_at']));
     $bundle->setHomepage(empty($data['homepage']) ? null : $data['homepage']);
     return true;
 }