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

Path::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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