1 | <?php |
||
47 | abstract class AbstractHierarchicalUri extends AbstractUri |
||
48 | { |
||
49 | /** |
||
50 | * Create a new instance of URI |
||
51 | * |
||
52 | * @param SchemeInterface $scheme |
||
53 | * @param UserInfoInterface $userInfo |
||
54 | * @param HostInterface $host |
||
55 | * @param PortInterface $port |
||
56 | * @param PathInterface $path |
||
57 | * @param QueryInterface $query |
||
58 | * @param FragmentInterface $fragment |
||
59 | */ |
||
60 | 563 | public function __construct( |
|
61 | SchemeInterface $scheme, |
||
62 | UserInfoInterface $userInfo, |
||
63 | HostInterface $host, |
||
64 | PortInterface $port, |
||
65 | PathInterface $path, |
||
66 | QueryInterface $query, |
||
67 | FragmentInterface $fragment |
||
68 | ) { |
||
69 | 563 | $this->scheme = $scheme; |
|
70 | 563 | $this->userInfo = $userInfo; |
|
71 | 563 | $this->host = $host; |
|
72 | 563 | $this->port = $port; |
|
73 | 563 | $this->path = $path; |
|
74 | 563 | $this->query = $query; |
|
75 | 563 | $this->fragment = $fragment; |
|
76 | 563 | $this->assertValidObject(); |
|
77 | 521 | } |
|
78 | |||
79 | /** |
||
80 | * Create a new instance from a string |
||
81 | * |
||
82 | * @param string $uri |
||
83 | * |
||
84 | * @return static |
||
85 | */ |
||
86 | 563 | public static function createFromString($uri = '') |
|
90 | |||
91 | /** |
||
92 | * Create a new instance from a hash of parse_url parts |
||
93 | * |
||
94 | * @param array $components a hash representation of the URI similar to PHP parse_url function result |
||
95 | * |
||
96 | * @return static |
||
97 | */ |
||
98 | 563 | public static function createFromComponents(array $components) |
|
99 | { |
||
100 | 563 | $components = self::normalizeUriHash($components); |
|
101 | |||
102 | 563 | return new static( |
|
103 | 563 | new Scheme($components['scheme']), |
|
104 | 563 | new UserInfo(new User($components['user']), new Pass($components['pass'])), |
|
105 | 563 | new Host($components['host']), |
|
106 | 563 | new Port($components['port']), |
|
107 | 563 | new Path($components['path']), |
|
108 | 563 | new Query($components['query']), |
|
109 | 563 | new Fragment($components['fragment']) |
|
110 | 375 | ); |
|
111 | } |
||
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | 9 | public static function __set_state(array $properties) |
|
128 | |||
129 | /** |
||
130 | * Tell whether URI with an authority are valid |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 563 | protected function isValidHierarchicalUri() |
|
140 | |||
141 | /** |
||
142 | * Tell whether the Auth URI is valid |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | 533 | protected function isAuthorityValid() |
|
155 | } |
||
156 |