Passed
Push — master ( 964e1c...49cc4f )
by Florian
01:49 queued 12s
created

PaginationService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
1
<?php
2
/**
3
 * Copyright (c) Florian Krämer
4
 *
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE.txt
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright     Copyright (c) Florian Krämer
10
 * @link          https://github.com/burzum/cakephp-service-layer
11
 * @since         1.0.0
12
 * @license       https://opensource.org/licenses/mit-license.php MIT License
13
 */
14
declare(strict_types = 1);
15
16
namespace Burzum\CakeServiceLayer\Service;
17
18
use Cake\Event\EventInterface;
19
use Cake\Http\ServerRequest;
20
21
/**
22
 * Pagination Service
23
 */
24
class PaginationService
25
{
26
    use ServicePaginatorTrait;
27
28
    /**
29
     * Server Request Object
30
     *
31
     * @var \Cake\Http\ServerRequest $request Server Request
32
     */
33
    protected $request;
34
35
    /**
36
     * Constructor
37
     *
38
     * @param \Cake\Http\ServerRequest $request Server Request
39
     */
40 1
    public function __construct(ServerRequest &$request)
41
    {
42 1
        $this->request = $request;
43
44 1
        $_this = $this;
45
        $this->getEventManager()->on('Service.afterPaginate', function (EventInterface $event) use ($_this) {
46 1
            $event->setData('request', $_this->addPagingParamToRequest($_this->request));
47 1
        });
48 1
    }
49
}
50