Url   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCompleteUrl() 0 11 3
1
<?php
2
/**
3
 * Copyright (c) 2010–2019 Ryan Parman <http://ryanparman.com>.
4
 * Copyright (c) 2016–2019 Contributors.
5
 *
6
 * http://opensource.org/licenses/Apache2.0
7
 */
8
9
declare(strict_types=1);
10
11
namespace SimplePie\UtilityPack\Util;
12
13
use Psr\Http\Message\ServerRequestInterface as Request;
14
15
class Url
16
{
17
    /**
18
     * Gets the complete URL that was requested.
19
     *
20
     * @return string The complete URL that was requested.
21
     */
22 7
    public static function getCompleteUrl(Request $request): string
23
    {
24 7
        $uri = $request->getUri();
25
26 7
        return \sprintf(
27 7
            '%s://%s%s%s%s',
28 7
            $uri->getScheme(),
29 7
            $uri->getHost(),
30 7
            $uri->getPath(),
31 7
            ('' !== $uri->getQuery() ? '?' . $uri->getQuery() : ''),
32 7
            ('' !== $uri->getFragment() ? '#' . $uri->getFragment() : '')
33
        );
34
    }
35
}
36