Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzRootComponent
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 4
42
0.00% covered (danger)
0.00%
0 / 1
 getPageTitle
n/a
0 / 0
n/a
0 / 0
0
 getPageDescription
n/a
0 / 0
n/a
0 / 0
0
 hasAccess
n/a
0 / 0
n/a
0 / 0
0
 searchSql
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 searchSqlWhenHasAccess
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getHtml
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getHtmlWhenHasAccess
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Components\Common;
4
5use Olz\Suche\Utils\SearchUtils;
6
7/**
8 * @phpstan-import-type SearchResult from SearchUtils
9 * @phpstan-import-type WithQuery from SearchUtils
10 *
11 * @template T
12 *
13 * @extends OlzComponent<T>
14 */
15abstract class OlzRootComponent extends OlzComponent {
16    abstract public function getPageTitle(): string;
17
18    abstract public function getPageDescription(): string;
19
20    abstract public function hasAccess(): bool;
21
22    /**
23     * @param array<string> $terms
24     *
25     * @return string|WithQuery|null
26     */
27    public function searchSql(array $terms): string|array|null {
28        if (!$this->hasAccess()) {
29            return null;
30        }
31        return $this->searchSqlWhenHasAccess($terms);
32    }
33
34    /**
35     * @param array<string> $terms
36     *
37     * @return string|WithQuery|null
38     */
39    public function searchSqlWhenHasAccess(array $terms): string|array|null {
40        $called_class = get_called_class();
41        throw new \Exception("{$called_class}::searchSqlWhenHasAccess is not implemented");
42    }
43
44    /** @param T $args */
45    public function getHtml(mixed $args): string {
46        if (!$this->hasAccess()) {
47            $this->httpUtils()->dieWithHttpError(403);
48        }
49        return $this->getHtmlWhenHasAccess($args);
50    }
51
52    /** @param T $args */
53    public function getHtmlWhenHasAccess(mixed $args): string {
54        $called_class = get_called_class();
55        throw new \Exception("{$called_class}::getHtmlWhenHasAccess is not implemented");
56    }
57}