Repository navigation
Expand file tree
/
Copy pathCommit.php
More file actions
86 lines (77 loc) · 2.08 KB
/
Copy pathCommit.php
File metadata and controls
86 lines (77 loc) · 2.08 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
<?php namespace Gitlab\Model;
use Gitlab\Client;
/**
* Class Commit
*
* @property-read string $id
* @property-read string $short_id
* @property-read string $title
* @property-read string $message
* @property-read string $author_name
* @property-read string $author_email
* @property-read string $authored_date
* @property-read string $committed_date
* @property-read string $created_at
* @property-read Commit[] $parents
* @property-read Node[] $tree
* @property-read User $committer
* @property-read User $author
* @property-read Project $project
*/
class Commit extends AbstractModel
{
/**
* @var array
*/
protected static $properties = array(
'id',
'short_id',
'parents',
'tree',
'title',
'message',
'author',
'author_name',
'author_email',
'committer',
'authored_date',
'committed_date',
'created_at',
'project'
);
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Commit
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$commit = new static($project, $data['id'], $client);
if (isset($data['parents'])) {
$parents = array();
foreach ($data['parents'] as $parent) {
$parents[] = static::fromArray($client, $project, $parent);
}
$data['parents'] = $parents;
}
if (isset($data['author'])) {
$data['author'] = User::fromArray($client, $data['author']);
}
if (isset($data['committer'])) {
$data['committer'] = User::fromArray($client, $data['committer']);
}
return $commit->hydrate($data);
}
/**
* @param Project $project
* @param int $id
* @param Client $client
*/
public function __construct(Project $project, $id = null, Client $client = null)
{
$this->setClient($client);
$this->setData('project', $project);
$this->setData('id', $id);
}
}