Repository navigation
Expand file tree
/
Copy pathMilestone.php
More file actions
115 lines (101 loc) · 2.52 KB
/
Copy pathMilestone.php
File metadata and controls
115 lines (101 loc) · 2.52 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php namespace Gitlab\Model;
use Gitlab\Client;
/**
* Class Milestone
*
* @property-read int $id
* @property-read int $iid
* @property-read int $project_id
* @property-read string $title
* @property-read string $description
* @property-read string $due_date
* @property-read string $state
* @property-read bool $closed
* @property-read string $updated_at
* @property-read string $created_at
* @property-read Project $project
*/
class Milestone extends AbstractModel
{
/**
* @var array
*/
protected static $properties = array(
'id',
'iid',
'project',
'project_id',
'title',
'description',
'due_date',
'state',
'closed',
'updated_at',
'created_at'
);
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Milestone
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$milestone = new static($project, $data['id'], $client);
return $milestone->hydrate($data);
}
/**
* @param Project $project
* @param int $id
* @param Client $client
*/
public function __construct(Project $project, $id, Client $client = null)
{
$this->setClient($client);
$this->setData('id', $id);
$this->setData('project', $project);
}
/**
* @return Milestone
*/
public function show()
{
$data = $this->api('milestones')->show($this->project->id, $this->id);
return static::fromArray($this->getClient(), $this->project, $data);
}
/**
* @param array $params
* @return Milestone
*/
public function update(array $params)
{
$data = $this->api('milestones')->update($this->project->id, $this->id, $params);
return static::fromArray($this->getClient(), $this->project, $data);
}
/**
* @return Milestone
*/
public function complete()
{
return $this->update(array('closed' => true));
}
/**
* @return Milestone
*/
public function incomplete()
{
return $this->update(array('closed' => false));
}
/**
* @return Issue[]
*/
public function issues()
{
$data = $this->api('milestones')->issues($this->project->id, $this->id);
$issues = array();
foreach ($data as $issue) {
$issues[] = Issue::fromArray($this->getClient(), $this->project, $issue);
}
return $issues;
}
}