| Total Complexity | 12 |
| Total Lines | 90 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class WebServer |
||
| 6 | { |
||
| 7 | /** @var string */ |
||
| 8 | private $host; |
||
| 9 | /** @var string */ |
||
| 10 | private $documentRoot; |
||
| 11 | /** @var int */ |
||
| 12 | private $pid; |
||
| 13 | /** @var int */ |
||
| 14 | private $port; |
||
| 15 | |||
| 16 | private const SERVER_TIMEOUT_SECONDS = 5; |
||
| 17 | |||
| 18 | public function __construct(string $host, string $documentRoot) |
||
| 22 | } |
||
| 23 | |||
| 24 | private function findFreePort(): int |
||
| 31 | } |
||
| 32 | |||
| 33 | public function start(): int |
||
| 64 | } |
||
| 65 | |||
| 66 | public function stop(): void |
||
| 67 | { |
||
| 68 | \exec('kill ' . (int)$this->pid); |
||
| 69 | } |
||
| 70 | |||
| 71 | public function getUrl($path = '', bool $https = false): string |
||
| 82 | } |
||
| 83 | |||
| 84 | private function canConnect(): bool |
||
| 95 | } |
||
| 96 | } |
||
| 97 |