v1.2 #3

Manually merged
jhodges merged 25 commits from develop into master 2019-09-07 08:53:26 +01:00
Showing only changes of commit a6bb48ef96 - Show all commits

View File

@ -1,6 +1,8 @@
<?php <?php
class Repo{ class Repo{
private $cache=[];
public function __construct(Client $client,$user,$repo){ public function __construct(Client $client,$user,$repo){
$this->client=$client; $this->client=$client;
$this->user=$user; $this->user=$user;
@ -29,9 +31,12 @@ class Repo{
} }
public function getLabelByName($name){ public function getLabelByName($name){
$url="repos/{$this->user}/{$this->repo}/labels"; if(!$this->cache['lables']){
$data=$this->client->request($url); $url="repos/{$this->user}/{$this->repo}/labels";
foreach($data as $datum){ $this->cache['lables']=$this->client->request($url);
}
foreach($this->cache['lables'] as $datum){
if($datum->name==$name){ if($datum->name==$name){
$datum->url=$url."/".$datum->id; // not set by api for some reason (bug?) $datum->url=$url."/".$datum->id; // not set by api for some reason (bug?)
return new Label($this,$datum); return new Label($this,$datum);