Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OlzHeader | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getHtml | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Components\Page\OlzHeader; |
| 4 | |
| 5 | use Olz\Components\Common\OlzComponent; |
| 6 | use Olz\Components\Page\OlzHeaderWithoutRouting\OlzHeaderWithoutRouting; |
| 7 | |
| 8 | /** @extends OlzComponent<array<string, mixed>> */ |
| 9 | class OlzHeader extends OlzComponent { |
| 10 | public function getHtml(mixed $args): string { |
| 11 | $is_insecure_nonlocal = !($_SERVER['HTTPS'] ?? false) && preg_match('/olzimmerberg\.ch/', $_SERVER['HTTP_HOST']); |
| 12 | $host_has_www = preg_match('/www\./', $_SERVER['HTTP_HOST']); |
| 13 | $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); |
| 14 | if ($is_insecure_nonlocal || $host_has_www) { |
| 15 | $request_uri = $_SERVER['REQUEST_URI']; |
| 16 | $this->httpUtils()->redirect("https://{$host}{$request_uri}", 308); |
| 17 | } |
| 18 | return OlzHeaderWithoutRouting::render($args, $this); |
| 19 | } |
| 20 | } |