Passed
Push — 0.8.x ( fca16e...a09e23 )
by Alexander
07:28 queued 04:00
created

RequestUtils   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 18
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizedQueryString() 0 9 2
1
<?php
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2023 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Components\Http\Helpers;
24
25
/**
26
 * Allows to use static methods referring normalized HTTP requests.
27
 */
28
class RequestUtils
29
{    
30
    /**
31
     * Normalizes a query string.
32
     * 
33
     * @param  string  $query
34
     * 
35
     * @return string
36
     */
37
    public static function normalizedQueryString(?string $query): string
38
    {
39
        if ('' === ($query ?? '')) {
40
            return '';
41
        }
42
43
        ksort([$query]);
0 ignored issues
show
Bug introduced by
array($query) cannot be passed to ksort() as the parameter $array expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        ksort(/** @scrutinizer ignore-type */ [$query]);
Loading history...
44
45
        return http_build_query([$query], '', '&', \PHP_QUERY_RFC3986);
46
    }
47
}