src/Kreta/Component/VCS/Repository/BranchRepository.php
public function findOrCreateBranch(RepositoryInterface $repository, $branchName)
    {
        try {
            return $this->findOneBy(['name' => $branchName, 'repository' => $repository], false);
        } catch (NoResultException $e) {
            $branch = new Branch();
            $branch
                ->setName($branchName)
                ->setRepository($repository);

            $this->persist($branch);

            return $branch;
        }
    }
public function findOrCreateBranch(RepositoryInterface $repository, $branchName)
    {
        try {
            return $this->findOneBy(['name' => $branchName, 'repository' => $repository], false);
        } catch (NoResultException $e) {
            $branch = new Branch();
            $branch
                ->setName($branchName)
                ->setRepository($repository);

            $this->persist($branch);

            return $branch;
        }
    }
public function findOrCreateBranch ( RepositoryInterface $ repository , $ branchName ) { try { return $ this -> findOneBy ( [ 'name' => $ branchName , 'repository' => $ repository ] , false ) ; } catch ( NoResultException $ e ) { $ branch = new Branch ( ) ; $ branch -> setName ( $ branchName ) -> setRepository ( $ repository ) ; $ this -> persist ( $ branch ) ; return $ branch ; } }
Tries to find a branch by repository and branch name and throws exception if is not able to do so.

@param \Kreta\Component\VCS\Model\Interfaces\RepositoryInterface $repository The repository
@param string                                                    $branchName The branch name

@return \Kreta\Component\VCS\Model\Interfaces\BranchInterface
Tries to find a branch by repository and branch name and throws exception if is not able to do so .