Passed
Push — master ( 69013a...5649e5 )
by Joshua
11:51 queued 09:34
created

ParseFilter::generateQueryString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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