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

PaginationDataHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A retrieveData() 0 12 2
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