| Total Complexity | 10 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 9 | final class Configuration |
||
| 10 | { |
||
| 11 | private int $logLevel = Logger::INFO; |
||
| 12 | |||
| 13 | /** @var array<UriInterface> */ |
||
| 14 | private array $websocketAddresses = []; |
||
| 15 | |||
| 16 | /** @var array<ServerAddress> */ |
||
| 17 | private array $bind = []; |
||
| 18 | |||
| 19 | private Token $githubToken; |
||
| 20 | |||
| 21 | 13 | public function __construct(Token $githubToken) |
|
| 22 | { |
||
| 23 | 13 | $this->githubToken = $githubToken; |
|
| 24 | } |
||
| 25 | |||
| 26 | 1 | public function setLogLevel(int $logLevel): self |
|
| 27 | { |
||
| 28 | 1 | $this->logLevel = $logLevel; |
|
| 29 | |||
| 30 | 1 | return $this; |
|
| 31 | } |
||
| 32 | |||
| 33 | 2 | public function getLogLevel(): int |
|
| 34 | { |
||
| 35 | 2 | return $this->logLevel; |
|
| 36 | } |
||
| 37 | |||
| 38 | 9 | public function addWebsocketAddress(UriInterface $address): self |
|
| 39 | { |
||
| 40 | 9 | $this->websocketAddresses[] = $address; |
|
| 41 | |||
| 42 | 9 | return $this; |
|
| 43 | } |
||
| 44 | |||
| 45 | 3 | public function websocketAddressExists(string $origin): bool |
|
| 46 | { |
||
| 47 | 3 | foreach ($this->websocketAddresses as $websocketAddress) { |
|
| 48 | 3 | if ((string) $websocketAddress === $origin) { |
|
| 49 | 2 | return true; |
|
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | 2 | return false; |
|
| 54 | } |
||
| 55 | |||
| 56 | 9 | public function bind(ServerAddress $address): self |
|
| 57 | { |
||
| 58 | 9 | $this->bind[] = $address; |
|
| 59 | |||
| 60 | 9 | return $this; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @return array<ServerAddress> |
||
| 65 | */ |
||
| 66 | 2 | public function getServerAddresses(): array |
|
| 69 | } |
||
| 70 | |||
| 71 | 2 | public function getGithubToken(): Token |
|
| 74 | } |
||
| 75 | } |
||
| 76 |