1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace AppBuilder\Application\Configuration\ValueObject; |
6
|
|
|
|
7
|
|
|
use AppBuilder\Application\Configuration\Exception\InvalidApplicationParamsException; |
8
|
|
|
use AppBuilder\Application\Configuration\ParametersValidator; |
9
|
|
|
|
10
|
|
|
class Parameters |
11
|
|
|
{ |
12
|
|
|
/** @var array */ |
13
|
|
|
private $paramsArray; |
14
|
|
|
|
15
|
|
|
public function __construct(array $paramsArray) |
16
|
|
|
{ |
17
|
|
|
if (!ParametersValidator::validate($paramsArray)) { |
18
|
|
|
throw new InvalidApplicationParamsException('Invalid application parameters'); |
19
|
|
|
} |
20
|
|
|
$this->paramsArray = $paramsArray; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Returns jira host. |
25
|
|
|
*/ |
26
|
|
|
public function jiraHost() : string |
27
|
|
|
{ |
28
|
|
|
return $this->paramsArray['parameters']['jira.host']; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Returns jira auth user. |
33
|
|
|
*/ |
34
|
|
|
public function authenticationUser() : string |
35
|
|
|
{ |
36
|
|
|
return $this->paramsArray['parameters']['jira.authentication.username']; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Returns jira auth password. |
41
|
|
|
*/ |
42
|
|
|
public function authenticationPassword() : string |
43
|
|
|
{ |
44
|
|
|
return $this->paramsArray['parameters']['jira.authentication.password']; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns jira projects to watch. |
49
|
|
|
*/ |
50
|
|
|
public function jiraWatchProjects() : array |
51
|
|
|
{ |
52
|
|
|
return $this->paramsArray['parameters']['jira.watch.projects']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns jira deploy status. |
57
|
|
|
*/ |
58
|
|
|
public function jiraDeployStatus() : string |
59
|
|
|
{ |
60
|
|
|
return $this->paramsArray['parameters']['jira.trigger.deploy.state']; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Returns jira remove status. |
65
|
|
|
*/ |
66
|
|
|
public function jiraRemoveStatuses() : array |
67
|
|
|
{ |
68
|
|
|
return $this->paramsArray['parameters']['jira.trigger.remove.states']; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Returns jira search max results |
73
|
|
|
*/ |
74
|
|
|
public function jiraSearchMaxResults() : int |
75
|
|
|
{ |
76
|
|
|
return $this->paramsArray['parameters']['jira.search.max.results']; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns bitbucket repository ssh host. |
81
|
|
|
*/ |
82
|
|
|
public function bitbucketRepositoryHost() : string |
83
|
|
|
{ |
84
|
|
|
return $this->paramsArray['parameters']['bitbucket.repository.ssh.host']; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns username. |
89
|
|
|
*/ |
90
|
|
|
public function username() : string |
91
|
|
|
{ |
92
|
|
|
return $this->paramsArray['parameters']['server.username']; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns path to test instances directory. |
97
|
|
|
*/ |
98
|
|
|
public function projectsHomeDir() : string |
99
|
|
|
{ |
100
|
|
|
return $this->paramsArray['parameters']['server.user.project.homedir']; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Returns server host directory. |
105
|
|
|
*/ |
106
|
|
|
public function serverHostDir() : string |
107
|
|
|
{ |
108
|
|
|
return $this->paramsArray['parameters']['server.vhost.dir']; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Returns server host public directory. |
113
|
|
|
*/ |
114
|
|
|
public function serverPublicHostDir() : string |
115
|
|
|
{ |
116
|
|
|
return $this->paramsArray['parameters']['server.vhost.dir.public']; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Returns home directory. |
121
|
|
|
*/ |
122
|
|
|
public function homeDirectory() : string |
123
|
|
|
{ |
124
|
|
|
return $this->paramsArray['parameters']['server.user.homedir']; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Returns snapshot file name. |
129
|
|
|
*/ |
130
|
|
|
public function snapshotFileName() : string |
131
|
|
|
{ |
132
|
|
|
return $this->paramsArray['parameters']['snapshot.filename']; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Combines path to particular test instance. |
137
|
|
|
*/ |
138
|
|
|
public function path(string $ticketKey) : string |
139
|
|
|
{ |
140
|
|
|
return $this->projectsHomeDir() . $ticketKey; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Combines filepath to particular snapshot. |
145
|
|
|
*/ |
146
|
|
|
public function snapshotPath(string $ticketKey) : string |
147
|
|
|
{ |
148
|
|
|
return $this->path($ticketKey) . $this->snapshotFileName(); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Combines symlink target. |
153
|
|
|
*/ |
154
|
|
|
public function symlinkTarget(string $ticketKey) : string |
155
|
|
|
{ |
156
|
|
|
return $this->projectsHomeDir() . $ticketKey . $this->serverPublicHostDir(); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Combines symlink source. |
161
|
|
|
*/ |
162
|
|
|
public function symlinkSource(string $ticketKey) : string |
163
|
|
|
{ |
164
|
|
|
return $this->serverHostDir() . $this->username() . $this->serverPublicHostDir() . $ticketKey; |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|