Repository navigation
Expand file tree
/
Copy pathBranch.php
More file actions
61 lines (46 loc) · 1.59 KB
/
Copy pathBranch.php
File metadata and controls
61 lines (46 loc) · 1.59 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
<?php
namespace Gitlab\Model;
use Gitlab\Client;
use Gitlab\Api\AbstractApi as Api;
class Branch extends AbstractModel
{
protected static $_properties = array(
'name',
'commit',
'project',
'protected'
);
public static function fromArray(Client $client, Project $project, array $data)
{
$branch = new Branch($project, $data['name'], $client);
if (isset($data['commit'])) {
$data['commit'] = Commit::fromArray($client, $project, $data['commit']);
}
return $branch->hydrate($data);
}
public function __construct(Project $project, $name = null, Client $client = null)
{
$this->setClient($client);
$this->project = $project;
$this->name = $name;
}
public function show()
{
$data = $this->api('repositories')->branch($this->project->id, $this->name);
return Branch::fromArray($this->getClient(), $this->project, $data);
}
public function protect()
{
$data = $this->api('repositories')->protectBranch($this->project->id, $this->name);
return Branch::fromArray($this->getClient(), $this->project, $data);
}
public function unprotect()
{
$data = $this->api('repositories')->unprotectBranch($this->project->id, $this->name);
return Branch::fromArray($this->getClient(), $this->project, $data);
}
public function commits($page = 1, $per_page = Api::PER_PAGE)
{
return $this->project->commits($page, $per_page, $this->name);
}
}