PaginationService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
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