1 | <?php |
||
15 | class InMemoryFileFetcher implements FileFetcher { |
||
16 | |||
17 | private $files; |
||
18 | private $defaultContent; |
||
19 | |||
20 | /** |
||
21 | * @param string[] $files |
||
22 | * @param string|null $defaultContent Content that is returned when there is no matching entry in $files |
||
23 | * @throws InvalidArgumentException |
||
24 | */ |
||
25 | 9 | public function __construct( array $files, string $defaultContent = null ) { |
|
26 | 9 | foreach ( $files as $url => $fileContents ) { |
|
27 | 4 | if ( !is_string( $url ) || !is_string( $fileContents ) ) { |
|
28 | throw new InvalidArgumentException( 'Both file url and file contents need to be of type string' ); |
||
29 | } |
||
30 | } |
||
31 | |||
32 | 9 | $this->files = $files; |
|
33 | 9 | $this->defaultContent = $defaultContent; |
|
34 | 9 | } |
|
35 | |||
36 | /** |
||
37 | * @see FileFetcher::fetchFile |
||
38 | * @throws FileFetchingException |
||
39 | */ |
||
40 | 9 | public function fetchFile( string $fileUrl ): string { |
|
51 | |||
52 | } |
||
53 |