private function getForkeeInfo(array $event)
 {
     $owner = $event['payload']['forkee']['owner'];
     $ou = new User($owner['id'], $owner['login'], $owner['type']);
     $fork = new Repository($event['forkee']['id'], $event['forkee']['name']);
     $fork->setOwner($ou);
     return $fork;
 }
 public function getRepository(array $eventInfo)
 {
     if (!isset($eventInfo['repo'])) {
         throw new InvalidEventException(sprintf('Bad repository info for event ID "%d"', $this->getEventId($eventInfo)));
     }
     $repo = $eventInfo['repo'];
     $repository = new Repository($repo['id'], $repo['name']);
     if (isset($eventInfo['org'])) {
         $org = new Organization($eventInfo['org']['id'], $eventInfo['org']['login']);
         $repository->setOrganization($org);
     }
     return $repository;
 }
 private function processBranch(array $branch)
 {
     $b = new Branch();
     $b->setLabel($branch['label']);
     $b->setReferenceName($branch['ref']);
     $u = new User($branch['user']['id'], $branch['user']['login'], $branch['user']['type']);
     $b->setUser($u);
     if (!empty($branch['repo'])) {
         $repo = new Repository($branch['repo']['id'], $branch['repo']['name']);
         $owner = new User($branch['repo']['owner']['id'], $branch['repo']['owner']['login'], $branch['repo']['owner']['type']);
     } else {
         $repoId = crc32($u->getLogin() . $b->getLabel());
         $repoName = $b->getLabel();
         $repo = new Repository($repoId, $repoName);
         $owner = new User($u->getId(), $u->getLogin(), $branch['user']['type']);
     }
     $repo->setOwner($owner);
     $b->setRepository($repo);
     return $b;
 }
Esempio n. 4
0
 protected function getRepoOwner(Repository $repository)
 {
     $explRepoName = explode('/', $repository->getName());
     $repo_owner = $explRepoName[count($explRepoName) - 2];
     return $repo_owner;
 }