Passed
Pull Request — main (#4)
by Peter
06:44 queued 03:43
created

Url   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A toQuery() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Helper;
6
7
class Url
8
{
9
    /**
10
     * @param array<string,string> $parts
11
     *
12
     * @return string
13
     */
14
    public static function toQuery(array $parts): string
15
    {
16
        if (empty($parts)) {
17
            return '';
18
        }
19
20
        $tmp = [];
21
        foreach ($parts as $k => $v) {
22
            $tmp[] = sprintf('%s=%s', $k, urlencode($v));
23
        }
24
25
        return '?' . implode('&', $tmp);
26
    }
27
}
28