SimpleFileFetcher::fetchFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace FileFetcher;
6
7
/**
8
 * Adapter around file_get_contents.
9
 *
10
 * @since 3.0
11
 *
12
 * @licence BSD-3-Clause
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class SimpleFileFetcher implements FileFetcher {
16
17
	/**
18
	 * @see FileFetcher::fetchFile
19
	 * @throws FileFetchingException
20
	 */
21 4
	public function fetchFile( string $fileUrl ): string {
22 4
		$fileContent = @file_get_contents( $fileUrl );
23
24 4
		if ( is_string( $fileContent ) ) {
25 2
			return $fileContent;
26
		}
27
28 2
		throw new FileFetchingException( $fileUrl );
29
	}
30
31
}
32