Branch.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Gogs\API\Request {
  3. /**
  4. * A single Branch
  5. *
  6. * @author Joachim M. Giaever (joachim[]giaever.org)
  7. * @version 0.1
  8. */
  9. final class Branch extends Base {
  10. private $repo;
  11. public $branch_name;
  12. public $branch_commit;
  13. /**
  14. * Initialize a branch for the given repository.
  15. *
  16. * @see Base
  17. * @param string $api_url The API URL
  18. * @param string $api_token The API token
  19. * @param Repo $repo Related repository
  20. */
  21. public function __construct(string $api_url, string $api_token, Repo $repo) {
  22. parent::__construct($api_url, $api_token);
  23. $this->repo = $repo;
  24. }
  25. /**
  26. * @see Base
  27. */
  28. protected function set_scope(string $method) {
  29. switch ($method) {
  30. case "load":
  31. $this->scope = sprintf("/repos/%s/%s/branches/%s", $this->repo->owner, $this->repo->name, $this->name);
  32. return true;
  33. }
  34. return false;
  35. }
  36. }
  37. }
  38. ?>