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

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createPager() 0 8 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