Passed
Pull Request — master (#6)
by Joshua
09:39
created

ParseFilter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateQueryString() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the SeamsCMSDeliverySdk package.
7
 *
8
 * (c) Seams-CMS.com
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace SeamsCMS\Delivery;
15
16
use function GuzzleHttp\Psr7\build_query;
17
18
/**
19
 * Class Filter
20
 * @package SeamsCMS\Delivery
21
 */
22
class ParseFilter
23
{
24
    /**
25
     * @param Filter|null $filter
26
     * @return string
27
     */
28
    public static function generateQueryString(Filter $filter = null): string
29
    {
30
        if (is_null($filter)) {
31
            return "";
32
        }
33
34
        $params = [];
35
        $params['offset'] = $filter->getOffset();
36
        $params['limit'] = $filter->getLimit();
37
        $params['sort'] = $filter->getSort();
38
39
        return build_query($params);
40
    }
41
}
42