|
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 InvalidArgumentException; |
|
15
|
|
|
use League\Uri\Interfaces\Pass as PassInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Value object representing a URI pass component. |
|
19
|
|
|
* |
|
20
|
|
|
* @package League.uri |
|
21
|
|
|
* @author Ignace Nyamagana Butera <[email protected]> |
|
22
|
|
|
* @since 1.0.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
class Pass extends AbstractComponent implements PassInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @inheritdoc |
|
28
|
450 |
|
*/ |
|
29
|
|
|
protected function validate($str) |
|
30
|
450 |
|
{ |
|
31
|
255 |
|
if (!is_string($str) || !preg_match(',[/?#@],', $str)) { |
|
32
|
|
|
return parent::validate($str); |
|
33
|
|
|
} |
|
34
|
201 |
|
|
|
35
|
201 |
|
throw new InvalidArgumentException(sprintf( |
|
36
|
|
|
'The encoded pass component `%s` contains invalid characters `/?#@`', |
|
37
|
201 |
|
$str |
|
38
|
|
|
)); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @inheritdoc |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getContent() |
|
45
|
30 |
|
{ |
|
46
|
|
|
if (null === $this->data) { |
|
47
|
30 |
|
return $this->data; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$regexp = '/(?:[^'.self::$unreservedChars.self::$subdelimChars.'\:]+ |
|
51
|
|
|
|%(?!'.self::$encodedChars.'))/x'; |
|
52
|
|
|
|
|
53
|
2 |
|
return $this->encode((string) $this->data, $regexp); |
|
54
|
|
|
} |
|
55
|
2 |
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Return the decoded string representation of the component |
|
58
|
|
|
* |
|
59
|
|
|
* @return null|string |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getDecoded() |
|
62
|
|
|
{ |
|
63
|
|
|
if (null === $this->data) { |
|
64
|
|
|
return null; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $this->data; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @inheritdoc |
|
72
|
|
|
*/ |
|
73
|
|
|
public function __debugInfo() |
|
74
|
|
|
{ |
|
75
|
|
|
return ['pass' => $this->getContent()]; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|