/**
  * Handle the analyze branch command.
  *
  * @param \StyleCI\StyleCI\Commands\Analysis\AnalyzeBranchCommand $command
  *
  * @return void
  */
 public function handle(AnalyzeBranchCommand $command)
 {
     $repo = $command->repo;
     $branch = $command->branch;
     $commit = $this->branches->getCommit($repo, $branch);
     $message = Str::commit($this->commits->get($repo, $commit)['commit']['message']);
     $analysis = Analysis::create(['repo_id' => $repo->id, 'branch' => $branch, 'commit' => $commit, 'message' => $message, 'status' => Analysis::PENDING, 'hidden' => false]);
     $this->dispatch(new RunAnalysisJob($analysis));
 }
 /**
  * Handle the github pull request event.
  *
  * @param \StyleCI\StyleCI\Events\Repo\GitHub\GitHubPullRequestEvent $event
  *
  * @return void
  */
 public function handle(GitHubPullRequestEvent $event)
 {
     $data = $event->data;
     if (!$this->isValidBranch($data) || !$this->shouldAnalyze($data)) {
         return;
     }
     $pr = $data['number'];
     $commit = $data['pull_request']['head']['sha'];
     $message = Str::commit('Pull Request: ' . $data['pull_request']['title']);
     dispatch(new AnalyzePullRequestCommand($event->repo, $pr, $commit, $message));
 }
 /**
  * Handle the github push event.
  *
  * @param \StyleCI\StyleCI\Events\Repo\GitHub\GitHubPushEvent $event
  *
  * @return void
  */
 public function handle(GitHubPushEvent $event)
 {
     $data = $event->data;
     if (!$this->shouldAnalyze($data)) {
         return;
     }
     $branch = substr($data['ref'], 11);
     $commit = $data['head_commit']['id'];
     $message = Str::commit($data['head_commit']['message']);
     $this->dispatch(new AnalyzeCommitCommand($event->repo, $branch, $commit, $message));
 }