repos.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Client\Request {
  3. class Repos extends RequestBase {
  4. private $repo = array();
  5. protected function json_set_property($objs) {
  6. foreach ($objs as $key => $obj) {
  7. $this->repo[$key] = new Repos\Repo(
  8. sprintf("/repos/%s/%s",
  9. $obj->owner->username,
  10. $obj->name
  11. ),
  12. $this->token
  13. );
  14. $this->repo[$key]->json_set_property($obj);
  15. }
  16. }
  17. public function current() {
  18. return current($this->repo);
  19. }
  20. public function next() {
  21. return next($this->repo);
  22. }
  23. public function reset() {
  24. return reset($this->repo);
  25. }
  26. public function __destruct() {}
  27. }
  28. }
  29. namespace Client\Request\Repos {
  30. class Repo extends \Client\Request\RequestBase {
  31. public $rid;
  32. public $rowner;
  33. public $rname;
  34. public $rfull_name;
  35. public $rdescription;
  36. public $rprivate;
  37. public $rfork;
  38. public $rparent;
  39. public $rempty;
  40. public $rmirror;
  41. public $rsize;
  42. public $rhtml_url;
  43. public $rssh_url;
  44. public $rclone_url;
  45. public $rwebsite;
  46. public $rstars_count;
  47. public $rforks_count;
  48. public $rwathcers_count;
  49. public $ropen_issues_count;
  50. public $rpublic_branch;
  51. public $rcreated_at;
  52. public $rupdated_at;
  53. public $rpermissions;
  54. public function __construct($api_url, $token) {
  55. if (!strpos($api_url, API_URL))
  56. $api_url = sprintf("%s/%s", API_URL, $api_url);
  57. parent::__construct($api_url, $token);
  58. }
  59. protected function json_set_property($obj) {
  60. foreach($obj as $key => $value) {
  61. $key = 'r' . $key;
  62. if (property_exists($this, $key))
  63. $this->{$key} = $value;
  64. }
  65. }
  66. public function __destruct() {}
  67. }
  68. }