summaryrefslogtreecommitdiffstats
path: root/vendor/gipfl/icingaweb2/src/FakeRequest.php
blob: 854c26ec622fac0be592e649e5227ad49c512f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

namespace gipfl\IcingaWeb2;

use Icinga\Web\Request;
use RuntimeException;

class FakeRequest extends Request
{
    /** @var string */
    private static $baseUrl;

    public static function setConfiguredBaseUrl($url)
    {
        self::$baseUrl = $url;
    }

    public function setUrl(Url $url)
    {
        $this->url = $url;
        return $this;
    }

    public function getBaseUrl($raw = false)
    {
        if (self::$baseUrl === null) {
            throw new RuntimeException('Cannot determine base URL on CLI if not configured');
        } else {
            return self::$baseUrl;
        }
    }
}