|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DevBoardLib\GithubCore\Commit; |
|
4
|
|
|
|
|
5
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoId; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class GithubCommitSource. |
|
9
|
|
|
*/ |
|
10
|
|
|
class GithubCommitSource implements GithubCommit |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var GithubCommitSha */ |
|
13
|
|
|
private $sha; |
|
14
|
|
|
/** @var GithubRepoId */ |
|
15
|
|
|
protected $githubRepoId; |
|
16
|
|
|
|
|
17
|
|
|
/** @var GithubCommitAuthor */ |
|
18
|
|
|
private $author; |
|
19
|
|
|
|
|
20
|
|
|
/** @var GithubCommitCommitter */ |
|
21
|
|
|
private $committer; |
|
22
|
|
|
|
|
23
|
|
|
/** @var string */ |
|
24
|
|
|
private $message; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* GithubCommitSource constructor. |
|
28
|
|
|
* |
|
29
|
|
|
* @param GithubCommitSha $sha |
|
30
|
|
|
* @param GithubRepoId $githubRepoId |
|
31
|
|
|
* @param GithubCommitAuthor $author |
|
32
|
|
|
* @param GithubCommitCommitter $committer |
|
33
|
|
|
* @param string $message |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
GithubCommitSha $sha, |
|
37
|
|
|
GithubRepoId $githubRepoId, |
|
38
|
|
|
GithubCommitAuthor $author, |
|
39
|
|
|
GithubCommitCommitter $committer, |
|
40
|
|
|
$message |
|
41
|
|
|
) { |
|
42
|
|
|
$this->sha = $sha; |
|
43
|
|
|
$this->githubRepoId = $githubRepoId; |
|
44
|
|
|
$this->author = $author; |
|
45
|
|
|
$this->committer = $committer; |
|
46
|
|
|
$this->message = $message; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return GithubCommitSha |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getSha() : GithubCommitSha |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->sha; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return GithubRepoId |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getGithubRepoId() : GithubRepoId |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->githubRepoId; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return GithubCommitAuthor |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getAuthor() : GithubCommitAuthor |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->author; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return GithubCommitCommitter |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getCommitter() : GithubCommitCommitter |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->committer; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getMessage() : string |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->message; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return array |
|
91
|
|
|
*/ |
|
92
|
|
|
public function serialize() |
|
93
|
|
|
{ |
|
94
|
|
|
return [ |
|
95
|
|
|
'sha' => (string)$this->sha, |
|
96
|
|
|
'githubRepoId' => (string)$this->githubRepoId, |
|
97
|
|
|
'author' => $this->author->serialize(), |
|
98
|
|
|
'committer' => $this->committer->serialize(), |
|
99
|
|
|
'message' => $this->message, |
|
100
|
|
|
]; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @param array $data |
|
105
|
|
|
* |
|
106
|
|
|
* @throws \Exception |
|
107
|
|
|
* |
|
108
|
|
|
* @return static |
|
109
|
|
|
*/ |
|
110
|
|
|
public static function deserialize(array $data) |
|
111
|
|
|
{ |
|
112
|
|
|
return new static( |
|
113
|
|
|
new GithubCommitSha($data['sha']), |
|
114
|
|
|
new GithubRepoId($data['githubRepoId']), |
|
115
|
|
|
GithubCommitAuthor::deserialize($data['author']), |
|
116
|
|
|
GithubCommitCommitter::deserialize($data['committer']), |
|
117
|
|
|
$data['message'] |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|