Completed
Pull Request — master (#58)
by ignace nyamagana
03:51
created

Path   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 12
Bugs 1 Features 0
Metric Value
wmc 3
c 12
b 1
f 0
lcom 1
cbo 2
dl 0
loc 41
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getComponent() 0 4 1
A validate() 0 6 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
     * @inheritdoc
29
     */
30
    protected static $invalidCharactersRegex = ',[?#],';
31
32
    /**
33
     * new instance
34
     *
35
     * @param string $path the component value
36
     */
37 392
    public function __construct($path = '')
38
    {
39 392
        parent::__construct($this->validateString($path));
40 374
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 362
    public function getComponent()
46
    {
47 362
        return $this->encodePath($this->data);
48
    }
49
50
    /**
51
     * validate the submitted data
52
     *
53
     * @param string $path
54
     *
55
     * @return string
56
     */
57 380
    protected function validate($path)
58
    {
59 380
        $this->assertValidComponent($path);
60
61 374
        return $this->decodePath($path);
62
    }
63
}
64