fix indenting
This commit is contained in:
94
src/Repo.php
94
src/Repo.php
@@ -1,57 +1,57 @@
|
||||
<?php
|
||||
class Repo{
|
||||
|
||||
public function __construct(Client $client,$user,$repo){
|
||||
$this->client=$client;
|
||||
$this->user=$user;
|
||||
$this->repo=$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 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){
|
||||
$datum->url=$url."/".$datum->id; // not set by api for some reason (bug?)
|
||||
return new Label($this,$datum);
|
||||
}
|
||||
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);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
$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 createLabel($args){
|
||||
$url="repos/{$this->user}/{$this->repo}/labels";
|
||||
$data=$this->client->request($url,'POST',$args);
|
||||
$data->url=$url."/".$data->id; // not set by api for some reason (bug?)
|
||||
return new Label($this,$data);
|
||||
}
|
||||
public function getLabelByName($name){
|
||||
$url="repos/{$this->user}/{$this->repo}/labels";
|
||||
$data=$this->client->request($url);
|
||||
foreach($data as $datum){
|
||||
if($datum->name==$name){
|
||||
$datum->url=$url."/".$datum->id; // not set by api for some reason (bug?)
|
||||
return new Label($this,$datum);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function createIssue($args){
|
||||
$url="repos/{$this->user}/{$this->repo}/issues";
|
||||
$data=$this->client->request($url,'POST',$args);
|
||||
//$data->url=$url."/".$data->id; // not set by api for some reason (bug?)
|
||||
return new Issue($this,$data);
|
||||
}
|
||||
public function createLabel($args){
|
||||
$url="repos/{$this->user}/{$this->repo}/labels";
|
||||
$data=$this->client->request($url,'POST',$args);
|
||||
$data->url=$url."/".$data->id; // not set by api for some reason (bug?)
|
||||
return new Label($this,$data);
|
||||
}
|
||||
|
||||
public function createIssue($args){
|
||||
$url="repos/{$this->user}/{$this->repo}/issues";
|
||||
$data=$this->client->request($url,'POST',$args);
|
||||
//$data->url=$url."/".$data->id; // not set by api for some reason (bug?)
|
||||
return new Issue($this,$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user