Lines 91.66% 11 / 12
Methods 66.66% 2 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 readResponse 100.00% 4 / 4 100.00% 1 / 1 2
 getHomeUrl 80.00% 4 / 5 0.00% 0 / 1 3.07
 [BO\Zmsticketprinter\BaseController] __invoke 100.00% 3 / 3 100.00% 1 / 1 1
17class Home extends BaseController
18{
19    /**
20     * @SuppressWarnings(UnusedFormalParameter)
21     * @return ResponseInterface
22     */
23    #[\Override]
24    public function readResponse(
25        RequestInterface $request,
26        ResponseInterface $response,
27        array $args
28    ) {
29        $homeUrl = Helper\HomeUrl::sanitizeUrl(static::getHomeUrl($request));
30        if ($homeUrl === '') {
31            throw new Exception\HomeNotFound();
32        }
33
34        return Render::withLastModified($response, time(), '0')->withRedirect($homeUrl, 301);
35    }
36
37    public static function getHomeUrl(RequestInterface $request): string
38    {
39        $cookies = $request->getCookieParams();
40        $homeUrl = TicketprinterClient::getHomeUrl();
41        if (array_key_exists(TicketprinterClient::HOME_URL_COOKIE_NAME, $cookies) && ! $homeUrl) {
42            $homeUrl = $cookies[TicketprinterClient::HOME_URL_COOKIE_NAME];
43        }
44        return $homeUrl;
45    }
46}

Inherited from BO\Zmsticketprinter\BaseController

21    public function __invoke(RequestInterface $request, ResponseInterface $response, array $args)
22    {
23        $request = $this->initRequest($request);
24        $noCacheResponse = \BO\Slim\Render::withLastModified($response, time(), '0');
25        return $this->readResponse($request, $noCacheResponse, $args);
26    }