Completed
Push — master ( 4b40ba...4de594 )
by ignace nyamagana
03:31
created

Path   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 14
Bugs 1 Features 0
Metric Value
wmc 4
c 14
b 1
f 0
lcom 1
cbo 2
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContent() 0 4 1
A __toString() 0 4 1
A validate() 0 4 1
1
<?php
2
/**
3
 * League.Uri (http://uri.thephpleague.com)
4
 *
5
 * @package   League.uri
6
 * @author    Ignace Nyamagana Butera <[email protected]>
7
 * @copyright 2013-2015 Ignace Nyamagana Butera
8
 * @license   https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
9
 * @version   4.2.0
10
 * @link      https://github.com/thephpleague/uri/
11
 */
12
namespace League\Uri\Components;
13
14
use League\Uri\Interfaces\Path as PathInterface;
15
16
/**
17
 * Value object representing a URI path component.
18
 *
19
 * @package League.uri
20
 * @author  Ignace Nyamagana Butera <[email protected]>
21
 * @since   1.0.0
22
 */
23
class Path extends AbstractComponent implements PathInterface
24
{
25
    use PathTrait;
26
27
    /**
28
     * new instance
29
     *
30
     * @param string $path the component value
31
     */
32 476
    public function __construct($path = '')
33
    {
34 476
        parent::__construct($this->validateString($path));
35 464
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 452
    public function getContent()
41
    {
42 452
        return $this->encodePath($this->data);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48 452
    public function __toString()
49
    {
50 452
        return (string) $this->getContent();
51
    }
52
53
    /**
54
     * validate the submitted data
55
     *
56
     * @param string $path
57
     *
58
     * @return string
59
     */
60 464
    protected function validate($path)
61
    {
62 464
        return $this->decodePath($path);
63
    }
64
}
65