| Total Complexity | 5 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class FakeAdapter implements ListBuilderAdapter |
||
| 7 | { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Records to be returned |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $records = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor |
||
| 18 | * |
||
| 19 | * @param array $records |
||
| 20 | */ |
||
| 21 | public function __construct(array $records = [ |
||
| 22 | [ |
||
| 23 | 'id' => 1, |
||
| 24 | ], |
||
| 25 | [ |
||
| 26 | 'id' => 2, |
||
| 27 | ] |
||
| 28 | ]) |
||
| 29 | { |
||
| 30 | $this->records = $records; |
||
| 31 | |||
| 32 | foreach ($this->records as $i => $record) { |
||
| 33 | $this->records[$i] = (object) $record; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Method returns all vailable records |
||
| 39 | * |
||
| 40 | * @return array all vailable records |
||
| 41 | */ |
||
| 42 | public function all(): array |
||
| 43 | { |
||
| 44 | return $this->records; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Method returns a subset from vailable records |
||
| 49 | * |
||
| 50 | * @param array $order |
||
| 51 | * order settings |
||
| 52 | * @param int $from |
||
| 53 | * the beginning of the bunch |
||
| 54 | * @param int $limit |
||
| 55 | * the size of the batch |
||
| 56 | * @return array subset from vailable records |
||
| 57 | */ |
||
| 58 | public function getRecords(array $order, int $from, int $limit): array |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * |
||
| 65 | * {@inheritdoc} |
||
| 66 | * @see ListBuilderAdapter::preprocessListItem($record) |
||
| 67 | */ |
||
| 68 | public function preprocessListItem(object $record): object |
||
| 71 | } |
||
| 72 | } |
||
| 73 |