| Total Complexity | 10 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| 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 | public function __construct(Token $githubToken) |
||
| 22 | { |
||
| 23 | $this->githubToken = $githubToken; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function setLogLevel(int $logLevel): self |
||
| 27 | { |
||
| 28 | $this->logLevel = $logLevel; |
||
| 29 | |||
| 30 | return $this; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getLogLevel(): int |
||
| 34 | { |
||
| 35 | return $this->logLevel; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function addWebsocketAddress(UriInterface $address): self |
||
| 39 | { |
||
| 40 | $this->websocketAddresses[] = $address; |
||
| 41 | |||
| 42 | return $this; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function websocketAddressExists(string $origin): bool |
||
| 46 | { |
||
| 47 | foreach ($this->websocketAddresses as $websocketAddress) { |
||
| 48 | if ((string) $websocketAddress === $origin) { |
||
| 49 | return true; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | return false; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function bind(ServerAddress $address): self |
||
| 57 | { |
||
| 58 | $this->bind[] = $address; |
||
| 59 | |||
| 60 | return $this; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @return array<ServerAddress> |
||
| 65 | */ |
||
| 66 | public function getServerAddresses(): array |
||
| 69 | } |
||
| 70 | |||
| 71 | public function getGithubToken(): Token |
||
| 74 | } |
||
| 75 | } |
||
| 76 |