| Total Complexity | 5 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class OriginComponent |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var false|resource |
||
| 13 | */ |
||
| 14 | private $client; |
||
| 15 | |||
| 16 | |||
| 17 | /** |
||
| 18 | * @var ServerConfig |
||
| 19 | */ |
||
| 20 | private ServerConfig $config; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * OriginComponent constructor. |
||
| 24 | * @param ServerConfig $config |
||
| 25 | * @param false|resource $client |
||
| 26 | */ |
||
| 27 | public function __construct(ServerConfig $config, $client) |
||
| 28 | { |
||
| 29 | $this->config = $config; |
||
| 30 | $this->client = $client; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Checks if there is a compatible origin header came from client |
||
| 35 | * @param string $headers |
||
| 36 | * @return bool |
||
| 37 | * @throws \Exception |
||
| 38 | */ |
||
| 39 | public function checkOrigin(string $headers): bool |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $msg |
||
| 59 | * @throws \Exception |
||
| 60 | */ |
||
| 61 | private function sendAndClose(string $msg): void |
||
| 66 | } |
||
| 67 | } |