Completed
Push — master ( 763db7...ef6780 )
by ignace nyamagana
04:05
created

Fragment   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 13
Bugs 1 Features 1
Metric Value
wmc 5
c 13
b 1
f 1
lcom 1
cbo 1
dl 0
loc 45
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContent() 0 11 2
A getValue() 0 4 1
A getUriComponent() 0 9 2
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\Fragment as FragmentInterface;
15
16
/**
17
 * Value object representing a URI fragment component.
18
 *
19
 * @package League.uri
20
 * @author  Ignace Nyamagana Butera <[email protected]>
21
 * @since   1.0.0
22
 */
23
class Fragment extends AbstractComponent implements FragmentInterface
24
{
25
    /**
26
     * Returns the component literal value
27
     *
28
     * @return string|null
29
     */
30 760
    public function getContent()
31
    {
32 760
        if (null === $this->data) {
33 456
            return null;
34
        }
35
36 391
        $regexp = '/(?:[^'.self::$unreservedChars.self::$subdelimChars.'\:\/@\?]+
37 391
            |%(?!'.self::$encodedChars.'))/x';
38
39 391
        return $this->encode($this->data, $regexp);
40
    }
41
42
    /**
43
     * Return the decoded string representation of the component
44
     *
45
     * @return string
46
     */
47 30
    public function getValue()
48
    {
49 30
        return (string) $this->data;
50
    }
51
52
    /**
53
     * Returns the instance string representation
54
     * with its optional URI delimiters
55
     *
56
     * @return string
57
     */
58 725
    public function getUriComponent()
59
    {
60 725
        $component = $this->__toString();
61 725
        if (null !== $this->data) {
62 383
            return FragmentInterface::DELIMITER.$component;
63
        }
64
65 429
        return $component;
66
    }
67
}
68