1
|
|
|
<?php |
2
|
|
|
namespace DevBoardLib\GithubCore\Branch; |
3
|
|
|
|
4
|
|
|
use DevBoardLib\GithubCore\Commit\GithubCommit; |
5
|
|
|
use DevBoardLib\GithubCore\Commit\GithubCommitId; |
6
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepo; |
7
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoId; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class GithubBranchSource. |
11
|
|
|
*/ |
12
|
|
View Code Duplication |
class GithubBranchSource implements GithubBranch |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
/** @var GithubBranchId */ |
15
|
|
|
private $id; |
16
|
|
|
|
17
|
|
|
/** @var GithubRepo */ |
18
|
|
|
private $repo; |
19
|
|
|
|
20
|
|
|
/** @var string */ |
21
|
|
|
private $name; |
22
|
|
|
|
23
|
|
|
/** @var GithubCommit */ |
24
|
|
|
private $lastCommit; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* GithubBranchSource constructor. |
28
|
|
|
* |
29
|
|
|
* @param GithubBranchId $id |
30
|
|
|
* @param GithubRepo $repo |
31
|
|
|
* @param string $name |
32
|
|
|
* @param GithubCommit $lastCommit |
33
|
|
|
*/ |
34
|
|
|
public function __construct(GithubBranchId $id, GithubRepo $repo, $name, GithubCommit $lastCommit) |
35
|
|
|
{ |
36
|
|
|
$this->id = $id; |
37
|
|
|
$this->repo = $repo; |
38
|
|
|
$this->name = $name; |
39
|
|
|
$this->lastCommit = $lastCommit; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** @return GithubBranchId */ |
43
|
|
|
public function getId() |
44
|
|
|
{ |
45
|
|
|
return $this->id; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** @return GithubRepoId */ |
49
|
|
|
public function getRepoId() |
50
|
|
|
{ |
51
|
|
|
return $this->repo->getId(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** @return GithubRepo */ |
55
|
|
|
public function getRepo() |
56
|
|
|
{ |
57
|
|
|
return $this->repo; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** @return string */ |
61
|
|
|
public function getName() |
62
|
|
|
{ |
63
|
|
|
return $this->name; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** @return GithubCommitId */ |
67
|
|
|
public function getLastCommitId() |
68
|
|
|
{ |
69
|
|
|
return $this->lastCommit->getId(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** @return GithubCommit */ |
73
|
|
|
public function getLastCommit() |
74
|
|
|
{ |
75
|
|
|
return $this->lastCommit; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.