packages/requirements/tests/Fake/UnreadableSource.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Fake;
6
7use Override;
8use Requirements\Model\Source;
9use Requirements\Source\SourceExtension;
10use RuntimeException;
11
12/**
13 * A source extension whose document can never be read, as when a download fails.
14 */
15final class UnreadableSource implements SourceExtension
16{
17 /**
18 * Fails to read the document, whatever the selector.
19 *
20 * @param Source $source The source declaration
21 * @param string $selector The selector
22 * @param string $directory The configuration directory
23 * @param bool $live Whether to read live
24 *
25 * @return list<\Requirements\Source\Unit> Never returns
26 *
27 * @throws RuntimeException Always, naming the source URI
28 */
29 #[Override]
30 public function select(Source $source, string $selector, string $directory, bool $live): array
31 {
32 throw new RuntimeException("Cannot read $source->uri.");
33 }
34}
35