This commit is contained in:
Bob E Moe
2019-06-25 09:15:51 +01:00
parent 4290eab80a
commit 5bac8a9772
7 changed files with 143 additions and 56 deletions

42
src/Repo.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
class Repo{
public function __construct(Client $client,$user,$repo){
$this->client=$client;
$this->user=$user;
$this->repo=$repo;
}
public function request($url, $type='GET', $postFields = null){
return $this->client->request($url, $type, $postFields);
}
public function forIssues($callback,$args=null){
$page=1;
while(1){
$url="repos/{$this->user}/{$this->repo}/issues?page=$page";
if($args){
$url.='&'.http_build_query($args);
}
$issues=$this->client->request($url);
if(!$issues) break;
foreach($issues as $data){
$issue=new Issue($this,$data);
call_user_func($callback,$issue);
}
$page++;
}
}
public function getLabelByName($name){
$url="repos/{$this->user}/{$this->repo}/labels";
$data=$this->client->request($url);
foreach($data as $datum){
if($datum->name==$name){
return new Label($this,$datum);
}
}
return null;
}
}