Uri   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 5 1
A create() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of slick/mvc package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Mvc\Http;
11
12
use Psr\Http\Message\UriInterface;
13
use Slick\Http\Uri as BaseUri;
14
15
/**
16
 * HTTP Uri
17
 *
18
 * @package Slick\Mvc\Http
19
 * @author  Filipe Silva <[email protected]>
20
 */
21
class Uri extends BaseUri
22
{
23
24
    /**
25
     * Retrieve the path segment of the URI.
26
     *
27
     * This method always return a string; if no path is present it will return
28
     * a '/' string to properly be routed by Aura Router. This differs from
29
     * the PSR-7 recommended implementation with this method should return an
30
     * empty string if the path is not present.
31
     *
32
     * @return string The path segment of the URI.
33
     */
34 4
    public function getPath()
35
    {
36 4
        $path = parent::getPath();
37 4
        return str_replace('//', '/', "/$path");
38
    }
39
40
    /**
41
     * Factory method to create an URI object from an existing
42
     * PSR-7 UriInterface.
43
     *
44
     * @param UriInterface $uri
45
     *
46
     * @return Uri
47
     */
48 4
    public static function create(UriInterface $uri)
49
    {
50 4
        return new static((string) $uri);
51
    }
52
}