packages/sql-catalog/src/Reporter/Html/Page/StatementIndexPage.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlCatalog\Reporter\Html\Page;
6
7use SqlCatalog\Reporter\Html\HtmlText;
8use SqlCatalog\Reporter\Html\ReportSite;
9use SqlCatalog\Reporter\Html\StatementList;
10
11/**
12 * Every statement, to be narrowed down from any direction.
13 *
14 * The other listings each take one route to a statement. This one takes
15 * none, so that a reader who wants the statements of one kind, or of one
16 * resolution, or those a namespace issues on one table, can narrow the whole
17 * catalog by those facts at once. Every count elsewhere in the report that
18 * is a link leads here with the narrowing already applied.
19 *
20 * @visibility root
21 */
22final class StatementIndexPage
23{
24 private HtmlText $text;
25
26 private StatementList $list;
27
28 /**
29 * Wires the page to the rendering it is written with.
30 */
31 public function __construct(?HtmlText $text = null, ?StatementList $list = null)
32 {
33 $this->text = $text ?? new HtmlText();
34 $this->list = $list ?? new StatementList($this->text);
35 }
36
37 /**
38 * The body of the listing.
39 */
40 public function render(ReportSite $site): string
41 {
42 $entries = $site->index()->entries();
43
44 return '<h1>Statements' . $this->text->count(count($entries), 'statement') . '</h1>'
45 . '<p class="lede">Every statement the source can issue, in the order it is written. '
46 . 'Narrow the listing by what a statement does, how far the analysis got with it, or any text in it.</p>'
47 . '<div data-narrowable>'
48 . $this->list->facets($entries)
49 . '<div class="active-filters" hidden></div>'
50 . $this->list->rows($site, ReportSite::STATEMENTS, $entries)
51 . '</div>';
52 }
53}
54