FakeEntityPagesFetcher::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Tests\Queryr\Replicator\Fixtures;
4
5
use Queryr\Replicator\EntitySource\EntityPageBatchFetcher;
6
use Queryr\Replicator\Model\EntityPage;
7
8
class FakeEntityPagesFetcher implements EntityPageBatchFetcher {
9
10
	private $pages;
11
12
	public function __construct( array $pages = [] ) {
13
		$this->pages = $pages;
14
	}
15
16
	/**
17
	 * @param string[] $entityIds
18
	 * @return EntityPage[]
19
	 */
20
	public function fetchEntityPages( array $entityIds ): array {
21
		$pages = [];
22
23
		foreach ( $entityIds as $entityId ) {
24
			if ( array_key_exists( $entityId, $this->pages ) ) {
25
				$pages[] = $this->pages[$entityId];
26
			}
27
		}
28
29
		return $pages;
30
	}
31
32
}