Completed
Push — SpyingFileFetcher ( 3875da )
by Jeroen De
04:40
created

SpyingFileFetcher::getFetchedUrls()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace FileFetcher;
4
5
/**
6
 * Decorator for FileFetcher objects that records file fetching calls.
7
 *
8
 * @since 3.2
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class SpyingFileFetcher implements FileFetcher {
14
15
	private $fileFetcher;
16
17
	private $fetchedUrls = [];
18
19
	public function __construct( FileFetcher $fileFetcher ) {
20
		$this->fileFetcher = $fileFetcher;
21
	}
22
23
	/**
24
	 * @see FileFetcher::fetchFile
25
	 *
26
	 * @param string $fileUrl
27
	 *
28
	 * @return string
29
	 * @throws FileFetchingException
30
	 */
31
	public function fetchFile( $fileUrl ) {
32
		$this->fetchedUrls[] = $fileUrl;
33
		return $this->fileFetcher->fetchFile( $fileUrl );
34
	}
35
36
	/**
37
	 * Returns an ordered list of fetched URLs. Duplicates are preserved.
38
	 *
39
	 * @return string[]
40
	 */
41
	public function getFetchedUrls() {
42
		return $this->fetchedUrls;
43
	}
44
45
}
46