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