/**
  * @param Branch $branch
  * @param string $domain
  * @param string $projectName
  * @param null|string $accessToken
  * @return Branch
  * @throws BuddySDKException
  */
 public function addBranch(Branch $branch, $domain, $projectName, $accessToken = null)
 {
     if (!$branch->getCommit() instanceof Commit) {
         throw new BuddySDKException('Commit with revision must be provided');
     }
     return $this->postJson($accessToken, ['name' => $branch->getName(), 'commit' => ['revision' => $branch->getCommit()->getRevision()]], '/workspaces/:domain/projects/:project_name/repository/branches', ['domain' => $domain, 'project_name' => $projectName])->getAsBranch();
 }
 public function testDeleteBranch()
 {
     $project = Utils::addProject();
     $file = Utils::addFile($project);
     $branch = new Branch();
     $branch->setName(Utils::randomString());
     $branch->setCommit($file->getCommit());
     $branch = Utils::getBuddy()->getApiBranches()->addBranch($branch, Utils::getWorkspaceDomain(), $project->getName());
     $resp = Utils::getBuddy()->getApiBranches()->deleteBranch(Utils::getWorkspaceDomain(), $project->getName(), $branch->getName());
     $this->assertEquals(true, $resp);
 }
 public function addBranch()
 {
     try {
         $buddy = new Buddy(['accessToken' => 'yourAccessToken']);
         $branch = new Branch();
         $head = new Commit();
         $head->setRevision('branch head revision');
         $branch->setName('dev');
         $branch->setCommit($head);
         $resp = $buddy->getApiBranches()->addBranch($branch, 'domain', 'projectName');
         var_dump($resp);
         exit;
     } catch (BuddyResponseException $e) {
         echo $e->getMessage();
         exit;
     } catch (BuddySDKException $e) {
         echo $e->getMessage();
         exit;
     }
 }