Completed
Push — master ( 9ec6aa...297e32 )
by Reen
07:19 queued 05:21
created

Factory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace ReenExeCubeTime\LightPaginator;
4
5
use ReenExeCubeTime\LightPaginator\Adapter\AdapterInterface;
6
7
class Factory
8
{
9
    /**
10
     * @var Core
11
     */
12
    private $core;
13
14
    /**
15
     * @param Core $core
16
     */
17
    public function __construct(Core $core)
18
    {
19
        $this->core = $core;
20
    }
21
22
    /**
23
     * @param AdapterInterface $adapter
24
     * @param $page
25
     * @param $limit
26
     * @return PagerInterface
27
     */
28
    public function createPager(AdapterInterface $adapter, $page, $limit)
29
    {
30
        $count = $adapter->getCount();
31
32
        $list = $adapter->getSlice($this->core->getOffset($page, $limit), $limit);
33
34
        return new Pager($page, $limit, $count, $list);
35
    }
36
}
37