1: <?php
2:
3: namespace Guzzle\Parser\Url;
4:
5: 6: 7:
8: class UrlParser implements UrlParserInterface
9: {
10: 11: 12:
13: protected $utf8 = false;
14:
15: 16: 17: 18: 19:
20: public function setUtf8Support($utf8)
21: {
22: $this->utf8 = $utf8;
23: }
24:
25: 26: 27:
28: public function parseUrl($url)
29: {
30: $parts = parse_url($url);
31:
32:
33: if ($this->utf8 && isset($parts['query'])) {
34: $queryPos = strpos($url, '?');
35: if (isset($parts['fragment'])) {
36: $parts['query'] = substr($url, $queryPos + 1, strpos($url, '#') - $queryPos - 1);
37: } else {
38: $parts['query'] = substr($url, $queryPos + 1);
39: }
40: }
41:
42: $parts['scheme'] = isset($parts['scheme']) ? $parts['scheme'] : null;
43: $parts['host'] = isset($parts['host']) ? $parts['host'] : null;
44: $parts['path'] = isset($parts['path']) ? $parts['path'] : null;
45: $parts['port'] = isset($parts['port']) ? $parts['port'] : null;
46: $parts['query'] = isset($parts['query']) ? $parts['query'] : null;
47: $parts['user'] = isset($parts['user']) ? $parts['user'] : null;
48: $parts['pass'] = isset($parts['pass']) ? $parts['pass'] : null;
49: $parts['fragment'] = isset($parts['fragment']) ? $parts['fragment'] : null;
50:
51: return $parts;
52: }
53: }
54: