-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGithubService.php
More file actions
58 lines (51 loc) · 1.17 KB
/
Copy pathGithubService.php
File metadata and controls
58 lines (51 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Erivello\GithubApiBundle\Service;
use Github;
/**
* GithubService
*
* @author Edoardo Rivello <edoardo.rivello@gmail.com>
*/
class GithubService
{
/**
* @var null|Github\HttpClient\CachedHttpClient
*/
protected $cache = null;
/**
* Constructor
*
* @param false|string $cacheDir
* @param false|string $file
*/
public function __construct($cacheDir = false, $file = false)
{
if ($cacheDir) $this->cache = new Github\HttpClient\CachedHttpClient(array('cache_dir' => $cacheDir));
if ($file)
{
$this->cache = new Github\HttpClient\CachedHttpClient(
array(),
null,
new Github\HttpClient\Cache\FilesystemCache($file)
);
}
}
/**
* Get a client object, so you can access to all GitHub
*
* @return Github\Client
*/
public function getClient()
{
return new Github\Client($this->cache);
}
/**
* Get cache
*
* @return null|Github\HttpClient\CachedHttpClient $cache
*/
public function getCache()
{
return $this->cache;
}
}