Passed
Push — master ( 8b508b...69c8c9 )
by Alexander
02:00
created

UrlHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 16
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A append() 0 13 2
1
<?php
2
3
namespace Horat1us\Yii\Helpers;
4
5
/**
6
 * Class UrlHelper
7
 * @package Horat1us\Yii\Helpers
8
 */
9
class UrlHelper
10
{
11 1
    public static function append(string $url, array $params = []): string
12
    {
13 1
        $parts = parse_url($url);
14 1
        parse_str($parts['query'], $existParams);
15
16 1
        $mergedParams = array_merge($existParams, $params);
17 1
        $parts['query'] = http_build_query($mergedParams);
18
19 1
        return function_exists('http_build_url')
20
            ? http_build_url($parts)
21 1
            : $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '?' . $parts['query'];
22
23
    }
24
}
25