Url   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addParamsToUrl() 0 7 2
A slashPrefix() 0 4 2
1
<?php
2
3
namespace Postpay\Http;
4
5
class Url
6
{
7
    /**
8
     * Appends params to the URL.
9
     *
10
     * @param string $url    The URL that will receive the params.
11
     * @param array  $params The params to append to the URL.
12
     *
13
     * @return string
14
     */
15 4
    public static function addParamsToUrl($url, array $params = [])
16
    {
17 4
        if (empty($params)) {
18 3
            return $url;
19
        }
20 1
        return $url . '?' . http_build_query($params, null, '&');
21
    }
22
23
    /**
24
     * Check for a "/" prefix and prepend it if not exists.
25
     *
26
     * @param string|null $path
27
     *
28
     * @return string|null
29
     */
30 5
    public static function slashPrefix($path)
31
    {
32 5
        return strpos($path, '/') === 0 ? $path : '/' . $path;
33
    }
34
}
35