public function it_will_return_new_entity_if_no_entity_found($repository, $factory, $em, GithubRepo $githubRepo, PullRequest $pullRequestValueObject, GithubPullRequest $githubPullRequestEntity)
 {
     $pullRequestValueObject->getNumber()->willReturn('31');
     $repository->findOneByNumber($githubRepo, '31')->willReturn(null);
     $factory->createFromValueObject($githubRepo, $pullRequestValueObject)->willReturn($githubPullRequestEntity);
     $em->persist($githubPullRequestEntity)->shouldBeCalled();
     $em->flush()->shouldBeCalled();
     $this->getOrCreate($githubRepo, $pullRequestValueObject)->shouldReturn($githubPullRequestEntity);
 }
 /**
  * @param GithubRepo  $githubRepo
  * @param PullRequest $pullRequestValueObject
  *
  * @return GithubPullRequest
  */
 public function createFromValueObject(GithubRepo $githubRepo, PullRequest $pullRequestValueObject)
 {
     $githubPullRequest = new GithubPullRequest();
     $githubPullRequest->setRepo($githubRepo);
     $githubPullRequest->setNumber($pullRequestValueObject->getNumber());
     $githubPullRequest->setTitle($pullRequestValueObject->getTitle());
     $githubPullRequest->setBody($pullRequestValueObject->getBody());
     $githubPullRequest->setState(GithubPullRequestState::convert($pullRequestValueObject->getState()));
     $githubPullRequest->setLocked($pullRequestValueObject->isLocked());
     $githubPullRequest->setMerged($pullRequestValueObject->isMerged());
     $githubPullRequest->setGithubCreatedAt($pullRequestValueObject->getGithubCreatedAt());
     $githubPullRequest->setGithubUpdatedAt($pullRequestValueObject->getGithubUpdatedAt());
     $this->mapper->map($pullRequestValueObject, $githubPullRequest);
     return $githubPullRequest;
 }
 /**
  * @param GithubRepo  $githubRepo
  * @param PullRequest $pullRequestValueObject
  *
  * @return mixed
  */
 public function get(GithubRepo $githubRepo, PullRequest $pullRequestValueObject)
 {
     return $this->repository->findOneByNumber($githubRepo, $pullRequestValueObject->getNumber());
 }