Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • UrlParser

Interfaces

  • UrlParserInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Parser\Url;
 4: 
 5: /**
 6:  * Parses URLs into parts using PHP's built-in parse_url() function
 7:  */
 8: class UrlParser implements UrlParserInterface
 9: {
10:     /**
11:      * @var bool Whether or not to work with UTF-8 strings
12:      */
13:     protected $utf8 = false;
14: 
15:     /**
16:      * Set whether or not to attempt to handle UTF-8 strings (still WIP)
17:      *
18:      * @param bool $utf8 Set to TRUE to handle UTF string
19:      */
20:     public function setUtf8Support($utf8)
21:     {
22:         $this->utf8 = $utf8;
23:     }
24: 
25:     /**
26:      * {@inheritdoc}
27:      */
28:     public function parseUrl($url)
29:     {
30:         $parts = parse_url($url);
31: 
32:         // Need to handle query parsing specially for UTF-8 requirements
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: 
php-coveralls API documentation generated by ApiGen 2.8.0