FakeAdapter::getRecords()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Mezon\Gui\Tests;
3
4
use Mezon\Gui\ListBuilder\ListBuilderAdapter;
5
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
59
    {
60
        return $this->all();
61
    }
62
63
    /**
64
     *
65
     * {@inheritdoc}
66
     * @see ListBuilderAdapter::preprocessListItem($record)
67
     */
68
    public function preprocessListItem(object $record): object
69
    {
70
        return $record;
71
    }
72
}
73