classCatalogArtifacts
final class CatalogArtifacts
The files a reporter produced, held in memory until something writes them.
Keeping the rendering separate from the writing is what lets the same reporter print to standard output and write into a directory.
Methods§
public function __construct(array<string, string> $files = [], string|null $primary = null)Parameters
$files | array<string, string> | Contents, keyed by the name to write them under |
$primary | string|null | The file a reader wants when only one can be shown |
public static function one(string $name, string $contents): selfThe artifacts holding one file.
Parameters
$name | string | |
$contents | string |
Returns
selfTest cases 6
ArtifactWriterTest::testWriteCreatesTheDirectoryAndTheFilescallsArtifactWriterTest::testWriteRefusesADirectoryItCannotCreatecallsCatalogArtifactsTest::testGetReadsOneFileByNamecallsCatalogArtifactsTest::testOneHoldsASingleFilecallsCatalogArtifactsTest::testPrimaryFallsBackToTheOnlyFilecallsCatalogArtifactsTest::testSoleAnswersOnlyForExactlyOneFilecalls
Called from 1
Calls 1
- new
selfline 39
public function all(): array<string, string>The contents, keyed by file name, in name order.
Returns
array<string, string>Test cases 1
Called from 2
Calls 1
- function-call
ksortline 50
public function names(): list<string>The file names, in order.
Returns
list<string>Test cases 2
Calls 2
- function-call
array_keysline 62 - method-call CatalogArtifacts::all() line 62
public function sole(): ?stringThe contents of the only file, or null when there is not exactly one.
Returns
?stringTest cases 1
Called from 1
public function primary(): ?stringThe contents a reader wants when only one file can be shown.
Writing into a directory can produce more than one file — a document and the schema that describes it. Printing cannot, so one of them is the one that gets printed.
Returns
?stringTest cases 3
Calls 1
- method-call CatalogArtifacts::sole() line 88
public function get(string $name): ?stringThe contents written under a name, or null when nothing is.
Parameters
$name | string |
Returns
?stringPrivate surface 2§
Implementation details, listed for orientation only.
private array<string, string> $filesprivate ?string $primaryTest cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
CatalogArtifactsTest::testAllReturnsTheFilesInNameOrdercallsCatalogArtifactsTest::testGetReadsOneFileByNamecallsCatalogArtifactsTest::testNamesListsTheFileNamescallsCatalogArtifactsTest::testOneHoldsASingleFilecallsCatalogArtifactsTest::testPrimaryFallsBackToTheOnlyFilecallsCatalogArtifactsTest::testPrimaryIsNullWhenTheNamedFileIsNotTherecallsCatalogArtifactsTest::testPrimaryIsTheFileAReaderWantsWhenOnlyOneCanBeShowncallsCatalogArtifactsTest::testSoleAnswersOnlyForExactlyOneFilecalls
Other tests reaching this symbol 7
Relations§
Instantiated in 2
Static calls 1
Method calls 1
Type declarations 5
- type SqlCatalog\Cli\ArtifactWriter packages/sql-catalog/src/Cli/ArtifactWriter.php:26
- type SqlCatalog\Core\Reporter\ReporterInterface packages/sql-catalog/src/Core/Reporter/ReporterInterface.php:33
- type SqlCatalog\Reporter\Html\HtmlReporter packages/sql-catalog/src/Reporter/Html/HtmlReporter.php:69
- type SqlCatalog\Reporter\Json\JsonReporter packages/sql-catalog/src/Reporter/Json/JsonReporter.php:69
- type SqlCatalog\Reporter\Text\TextReporter packages/sql-catalog/src/Reporter/Text/TextReporter.php:46