classSourceFetcher
final class SourceFetcher
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Downloads an upstream grammar or keyword source, keeping a copy for the next build.
Methods§
public function __construct(private string|null $cacheDirectory = null)Parameters
$cacheDirectory | string|null | Where downloaded files are kept, or null to keep none |
public function fetch(string $url): stringAnswers the contents of a URL, from the cache when it was fetched before.
Parameters
$url | string | Where the source is published |
Returns
string The contentsThrows
RuntimeException When the source cannot be fetchedTest cases 2
Calls 9
- method-call SourceFetcher::cachePath() line 34
- function-call
is_fileline 35 - function-call
file_get_contentsline 36 - method-call SourceFetcher::download() line 41
- new
RuntimeExceptionline 43 - function-call
is_dirline 46 - function-call
dirnameline 46 - function-call
mkdirline 47 - function-call
file_put_contentsline 49
public function download(string $url): string|nullDownloads a URL, quietly answering null when it cannot be reached.
Parameters
$url | string | Where the source is published |
Returns
string|null The contents, or null when the download failsTest cases 1
Called from 1
public function cachePath(string $url): string|nullAnswers where the copy of a URL is kept.
Parameters
$url | string | Where the source is published |
Returns
string|null The cache path, or null when nothing is keptTest cases 2
Called from 1
Private surface 1§
Implementation details, listed for orientation only.
private string|null $cacheDirectory = nullTest cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.