Repository navigation
Expand file tree
/
Copy pathSnippet.php
More file actions
64 lines (49 loc) · 1.49 KB
/
Copy pathSnippet.php
File metadata and controls
64 lines (49 loc) · 1.49 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
59
60
61
62
63
64
<?php
namespace Gitlab\Model;
use Gitlab\Client;
class Snippet extends AbstractModel
{
protected static $_properties = array(
'id',
'title',
'file_name',
'author',
'expires_at',
'updated_at',
'created_at',
'project'
);
public static function fromArray(Client $client, Project $project, array $data)
{
$snippet = new Snippet($project, $data['id'], $client);
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
return $snippet->hydrate($data);
}
public function __construct($project, $id = null, Client $client = null)
{
$this->setClient($client);
$this->project = $project;
$this->id = $id;
}
public function show()
{
$data = $this->api('snippets')->show($this->project->id, $this->id);
return Snippet::fromArray($this->getClient(), $this, $data);
}
public function update(array $params)
{
$data = $this->api('snippets')->update($this->project->id, $this->id, $params);
return Snippet::fromArray($this->getClient(), $this, $data);
}
public function content()
{
return $this->api('snippets')->content($this->project->id, $this->id);
}
public function remove()
{
$this->api('snippets')->remove($this->project->id, $this->id);
return true;
}
}