-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathConfiguration.php
111 lines (85 loc) · 2.23 KB
/
Configuration.php
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
<?php declare(strict_types=1);
namespace ekinhbayar\GitAmp;
use League\Uri\Contracts\UriInterface;
use Monolog\Logger;
use ekinhbayar\GitAmp\Github\Token;
final class Configuration
{
private int $logLevel = Logger::INFO;
/** @var array<UriInterface> */
private array $websocketAddresses = [];
/** @var array<ServerAddress> */
private array $bind = [];
/** @var array<string> */
private array $specialRepositories = [];
/** @var array<SslServerAddress> */
private array $bindSsl = [];
private Token $githubToken;
public function __construct(Token $githubToken)
{
$this->githubToken = $githubToken;
}
public function setLogLevel(int $logLevel): self
{
$this->logLevel = $logLevel;
return $this;
}
public function getLogLevel(): int
{
return $this->logLevel;
}
public function addWebsocketAddress(UriInterface $address): self
{
$this->websocketAddresses[] = $address;
return $this;
}
public function websocketAddressExists(string $origin): bool
{
foreach ($this->websocketAddresses as $websocketAddress) {
if ((string) $websocketAddress === $origin) {
return true;
}
}
return false;
}
public function bind(ServerAddress $address): self
{
$this->bind[] = $address;
return $this;
}
public function bindSsl(SslServerAddress $sslServerAddress): self
{
$this->bindSsl[] = $sslServerAddress;
return $this;
}
/**
* @return array<ServerAddress>
*/
public function getServerAddresses(): array
{
return $this->bind;
}
/**
* @return array<SslServerAddress>
*/
public function getSslServerAddresses(): array
{
return $this->bindSsl;
}
public function addSpecialRepository(string $repository): self
{
$this->specialRepositories[] = $repository;
return $this;
}
/**
* @return array<string>
*/
public function getSpecialRepositories(): array
{
return $this->specialRepositories;
}
public function getGithubToken(): Token
{
return $this->githubToken;
}
}