Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class InMemoryEntityIdPager implements SeekableEntityIdPager { |
||
18 | |||
19 | /** |
||
20 | * @var EntityId[] |
||
21 | */ |
||
22 | private $entityIds = []; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | private $offset = 0; |
||
28 | |||
29 | /** |
||
30 | * @param EntityId ...$ids |
||
31 | */ |
||
32 | public function __construct( ...$ids ) { |
||
33 | $this->entityIds = $ids; |
||
34 | } |
||
35 | |||
36 | public function addEntityId( EntityId $entityId ) { |
||
37 | $this->entityIds[] = $entityId; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @see EntityIdPager::fetchIds |
||
42 | * |
||
43 | * @param int $limit |
||
44 | * |
||
45 | * @return EntityId[] |
||
46 | */ |
||
47 | public function fetchIds( $limit ) { |
||
48 | $entityIds = array_slice( $this->entityIds, $this->offset, $limit ); |
||
49 | $this->offset += count( $entityIds ); |
||
50 | return $entityIds; |
||
51 | } |
||
52 | |||
53 | /** @inheritDoc */ |
||
54 | public function getPosition() { |
||
56 | } |
||
57 | |||
58 | /** @inheritDoc */ |
||
59 | public function setPosition( $position ) { |
||
61 | } |
||
62 | |||
64 |