Uri::getPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 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
}