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
|
817 |
|
public function getContent() |
31
|
|
|
{ |
32
|
817 |
|
if (null === $this->data) { |
33
|
513 |
|
return null; |
34
|
|
|
} |
35
|
|
|
|
36
|
403 |
|
$regexp = '/(?:[^'.self::$unreservedChars.self::$subdelimChars.'\:\/@\?]+ |
37
|
403 |
|
|%(?!'.self::$encodedChars.'))/x'; |
38
|
|
|
|
39
|
403 |
|
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
|
782 |
|
public function getUriComponent() |
59
|
|
|
{ |
60
|
782 |
|
$component = $this->__toString(); |
61
|
782 |
|
if (null !== $this->data) { |
62
|
392 |
|
return FragmentInterface::DELIMITER.$component; |
63
|
|
|
} |
64
|
|
|
|
65
|
486 |
|
return $component; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritdoc |
70
|
|
|
*/ |
71
|
2 |
|
public function __debugInfo() |
72
|
|
|
{ |
73
|
2 |
|
return ['fragment' => $this->getContent()]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|