Passed
Push — master ( 2840df...7f31e4 )
by Mikołaj
03:40
created

PaginationDataHandler::retrieveData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag. 
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project. 
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected]. 
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusElasticsearchPlugin\Controller\RequestDataHandler;
14
15
use Symfony\Component\HttpFoundation\Request;
16
17
final class PaginationDataHandler implements DataHandlerInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function retrieveData(Request $request): array
23
    {
24
        $data = [];
25
        $page = 1;
26
27
        if ($currentPage = $request->query->get(self::PAGE_INDEX)) {
28
            $page = (int) $currentPage;
29
        }
30
31
        $data[self::PAGE_INDEX] = $page;
32
33
        return $data;
34
    }
35
}
36