Completed
Pull Request — master (#3)
by Denis
01:34
created

ArrayDataProvider::getTotalPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Woo\GridView\DataProviders;
4
5
class ArrayDataProvider extends BaseDataProvider
6
{
7
    /**
8
     * @var array
9
     */
10
    private $data;
11
12
    public function __construct(array $data)
13
    {
14
        $this->data = $data;
15
    }
16
17
    /**
18
     * Should return total amount of rows
19
     * @return int
20
     */
21
    public function getCount() : int
22
    {
23
        return count($this->data);
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
30
    {
31
        return array_splice($this->data, ($page -1) * $perPage, $perPage);
32
    }
33
}