Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
UnpublishedAccessTrait
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 initializeUnpublishedAccess
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace BO\Zmscitizenapi\Controllers;
4
5use App;
6
7trait UnpublishedAccessTrait
8{
9    private bool $showUnpublished;
10    private function initializeUnpublishedAccess(): void
11    {
12        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
13            $domain = $_SERVER['HTTP_X_FORWARDED_HOST'];
14        } else {
15            $domain = $_SERVER['HTTP_HOST'] ?? '';
16        }
17
18        $showUnpublishedOnDomain = App::getAccessUnpublishedOnDomain();
19        $this->showUnpublished = !empty($showUnpublishedOnDomain)
20            && strpos($domain, $showUnpublishedOnDomain) !== false;
21    }
22}