Open Journal Systems  3.3.0
Guzzle\Http\Url Class Reference

Public Member Functions

 __clone ()
 
 __construct ($scheme, $host, $username=null, $password=null, $port=null, $path=null, QueryString $query=null, $fragment=null)
 
 __toString ()
 
 addPath ($relativePath)
 
 combine ($url, $strictRfc3986=false)
 
 getFragment ()
 
 getHost ()
 
 getParts ()
 
 getPassword ()
 
 getPath ()
 
 getPathSegments ()
 
 getPort ()
 
 getQuery ()
 
 getScheme ()
 
 getUsername ()
 
 isAbsolute ()
 
 normalizePath ()
 
 setFragment ($fragment)
 
 setHost ($host)
 
 setPassword ($password)
 
 setPath ($path)
 
 setPort ($port)
 
 setQuery ($query)
 
 setScheme ($scheme)
 
 setUsername ($username)
 

Static Public Member Functions

static buildUrl (array $parts)
 
static factory ($url)
 

Protected Attributes

 $fragment
 
 $host
 
 $password
 
 $path = ''
 
 $port
 
 $query
 
 $scheme
 
 $username
 

Detailed Description

Parses and generates URLs based on URL parts. In favor of performance, URL parts are not validated.

Definition at line 10 of file Url.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Http\Url::__construct (   $scheme,
  $host,
  $username = null,
  $password = null,
  $port = null,
  $path = null,
QueryString  $query = null,
  $fragment = null 
)

Create a new URL from URL parts

Parameters
string$schemeScheme of the URL
string$hostHost of the URL
string$usernameUsername of the URL
string$passwordPassword of the URL
int$portPort of the URL
string$pathPath of the URL
QueryString | array | string$queryQuery string of the URL
string$fragmentFragment of the URL

Definition at line 125 of file Url.php.

References Guzzle\Http\Url\$fragment, Guzzle\Http\Url\$host, Guzzle\Http\Url\$password, Guzzle\Http\Url\$path, Guzzle\Http\Url\$port, Guzzle\Http\Url\$query, Guzzle\Http\Url\$scheme, Guzzle\Http\Url\$username, Guzzle\Http\Url\setPath(), and Guzzle\Http\Url\setQuery().

Member Function Documentation

◆ __clone()

Guzzle\Http\Url::__clone ( )

Clone the URL

Definition at line 144 of file Url.php.

References Guzzle\Http\Url\$query.

◆ __toString()

Guzzle\Http\Url::__toString ( )

Returns the URL as a URL string

Returns
string

Definition at line 154 of file Url.php.

References Guzzle\Http\Url\buildUrl(), and Guzzle\Http\Url\getParts().

◆ addPath()

Guzzle\Http\Url::addPath (   $relativePath)

Add a relative path to the currently set path.

Parameters
string$relativePathRelative path to add
Returns
Url

Definition at line 330 of file Url.php.

References Guzzle\Http\Url\setPath().

◆ buildUrl()

static Guzzle\Http\Url::buildUrl ( array  $parts)
static

Build a URL from parse_url parts. The generated URL will be a relative URL if a scheme or host are not provided.

Parameters
array$partsArray of parse_url parts
Returns
string

Definition at line 62 of file Url.php.

References Guzzle\Http\Url\$scheme.

Referenced by Guzzle\Http\Url\__toString(), Guzzle\Http\Message\RequestFactory\fromParts(), Guzzle\Tests\Http\UrlTest\testAddsQueryStringIfPresent(), Guzzle\Tests\Http\UrlTest\testBuildsRelativeUrlsWithFalsyParts(), and Guzzle\Tests\Http\UrlTest\testHandlesPathsCorrectly().

◆ combine()

Guzzle\Http\Url::combine (   $url,
  $strictRfc3986 = false 
)

Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4.

Parameters
string$urlRelative URL to combine with
bool$strictRfc3986Set to true to use strict RFC 3986 compliance when merging paths. When first released, Guzzle used an incorrect algorithm for combining relative URL paths. In order to not break users, we introduced this flag to allow the merging of URLs based on strict RFC 3986 section 5.4.1. This means that "http://a.com/foo/baz" merged with "bar" would become "http://a.com/foo/bar". When this value is set to false, it would become "http://a.com/foo/baz/bar".
Returns
Url
Exceptions
InvalidArgumentExceptionhttp://tools.ietf.org/html/rfc3986#section-5.4

Definition at line 491 of file Url.php.

References Guzzle\Http\Url\$path, Guzzle\Http\Url\$query, Guzzle\Http\Url\factory(), Guzzle\Http\Url\isAbsolute(), and Guzzle\Http\Url\normalizePath().

◆ factory()

static Guzzle\Http\Url::factory (   $url)
static

Factory method to create a new URL from a URL string

Parameters
string$urlFull URL used to create a Url object
Returns
Url
Exceptions
InvalidArgumentException

Definition at line 34 of file Url.php.

References Guzzle\Http\QueryString\fromString().

Referenced by Guzzle\Http\Url\combine(), Guzzle\Http\RedirectPlugin\createRedirectRequest(), Guzzle\Http\Client\createRequest(), Guzzle\Plugin\Oauth\OauthPlugin\getStringToSign(), Guzzle\Http\Curl\CurlHandle\getUrl(), Guzzle\Http\Message\Request\setUrl(), Guzzle\Tests\Http\UrlTest\testAddsToPath(), Guzzle\Tests\Http\UrlTest\testAllowsFalsyUrlParts(), Guzzle\Tests\Http\UrlTest\testCloneCreatesNewInternalObjects(), Guzzle\Tests\Http\UrlTest\testCombinesUrls(), Guzzle\Tests\Http\UrlTest\testCombinesUrlsUsingRfc3986(), Guzzle\Tests\Http\UrlTest\testConvertsSpecialCharsInPathWhenCastingToString(), Guzzle\Tests\Http\Message\HttpRequestFactoryTest\testCreatesPutRequests(), Guzzle\Tests\Http\UrlTest\testEmptyUrl(), Guzzle\Tests\Http\UrlTest\testHandlesPathsCorrectly(), Guzzle\Tests\Http\UrlTest\testHasGettersAndSetters(), Guzzle\Tests\Http\UrlTest\testNormalizesPaths(), Guzzle\Tests\Parser\Cookie\CookieParserProvider\testParseCookie(), Guzzle\Tests\Http\UrlTest\testPortIsDeterminedFromScheme(), Guzzle\Tests\Http\Message\RequestTest\testRequestHasMutableUrl(), Guzzle\Tests\Http\UrlTest\testSetQueryAcceptsArray(), Guzzle\Tests\Http\UrlTest\testSettingHostWithPortModifiesPort(), Guzzle\Tests\Http\UrlTest\testUrlStoresParts(), Guzzle\Tests\Http\UrlTest\testValidatesUrlCanBeParsed(), and Guzzle\Tests\Http\UrlTest\testValidatesUrlPartsInFactory().

◆ getFragment()

Guzzle\Http\Url::getFragment ( )

Get the fragment part of the URL

Returns
null|string

Definition at line 448 of file Url.php.

References Guzzle\Http\Url\$fragment.

◆ getHost()

Guzzle\Http\Url::getHost ( )

Get the host part of the URL

Returns
string

Definition at line 205 of file Url.php.

References Guzzle\Http\Url\$host.

◆ getParts()

Guzzle\Http\Url::getParts ( )

Get the parts of the URL as an array

Returns
array

Definition at line 164 of file Url.php.

References Guzzle\Http\Url\$query, and Guzzle\Http\Url\getPath().

Referenced by Guzzle\Http\Url\__toString().

◆ getPassword()

Guzzle\Http\Url::getPassword ( )

Get the password part of the URL

Returns
null|string

Definition at line 382 of file Url.php.

References Guzzle\Http\Url\$password.

◆ getPath()

Guzzle\Http\Url::getPath ( )

Get the path part of the URL

Returns
string

Definition at line 348 of file Url.php.

References Guzzle\Http\Url\$path.

Referenced by Guzzle\Http\Url\getParts(), and Guzzle\Http\Url\getPathSegments().

◆ getPathSegments()

Guzzle\Http\Url::getPathSegments ( )

Get the path segments of the URL as an array

Returns
array

Definition at line 358 of file Url.php.

References Guzzle\Http\Url\getPath().

Referenced by Guzzle\Http\Url\normalizePath().

◆ getPort()

Guzzle\Http\Url::getPort ( )

Get the port part of the URl. Will return the default port for a given scheme if no port has been set.

Returns
int|null

Definition at line 259 of file Url.php.

References Guzzle\Http\Url\$port.

◆ getQuery()

Guzzle\Http\Url::getQuery ( )

Get the query part of the URL as a QueryString object

Returns
QueryString

Definition at line 416 of file Url.php.

References Guzzle\Http\Url\$query.

◆ getScheme()

Guzzle\Http\Url::getScheme ( )

Get the scheme part of the URL

Returns
string

Definition at line 235 of file Url.php.

References Guzzle\Http\Url\$scheme.

◆ getUsername()

Guzzle\Http\Url::getUsername ( )

Get the username part of the URl

Returns
null|string

Definition at line 406 of file Url.php.

References Guzzle\Http\Url\$username.

◆ isAbsolute()

Guzzle\Http\Url::isAbsolute ( )

Check if this is an absolute URL

Returns
bool

Definition at line 472 of file Url.php.

References Guzzle\Http\Url\$host.

Referenced by Guzzle\Http\Url\combine().

◆ normalizePath()

Guzzle\Http\Url::normalizePath ( )

Normalize the URL so that double slashes and relative paths are removed

Returns
Url

Definition at line 296 of file Url.php.

References Guzzle\Http\Url\getPathSegments().

Referenced by Guzzle\Http\Url\combine().

◆ setFragment()

Guzzle\Http\Url::setFragment (   $fragment)

Set the fragment part of the URL

Parameters
string$fragmentFragment to set
Returns
Url

Definition at line 460 of file Url.php.

References Guzzle\Http\Url\$fragment.

◆ setHost()

Guzzle\Http\Url::setHost (   $host)

Set the host of the request.

Parameters
string$hostHost to set (e.g. www.yahoo.com, yahoo.com)
Returns
Url

Definition at line 187 of file Url.php.

References Guzzle\Http\Url\$host, Guzzle\Http\Url\$port, and Guzzle\Http\Url\setPort().

◆ setPassword()

Guzzle\Http\Url::setPassword (   $password)

Set the password part of the URL

Parameters
string$passwordPassword to set
Returns
Url

Definition at line 370 of file Url.php.

References Guzzle\Http\Url\$password.

◆ setPath()

Guzzle\Http\Url::setPath (   $path)

Set the path part of the URL

Parameters
array | string$pathPath string or array of path segments
Returns
Url

Definition at line 279 of file Url.php.

References Guzzle\Http\Url\$path.

Referenced by Guzzle\Http\Url\__construct(), and Guzzle\Http\Url\addPath().

◆ setPort()

Guzzle\Http\Url::setPort (   $port)

Set the port part of the URL

Parameters
int$portPort to set
Returns
Url

Definition at line 247 of file Url.php.

References Guzzle\Http\Url\$port.

Referenced by Guzzle\Http\Url\setHost().

◆ setQuery()

Guzzle\Http\Url::setQuery (   $query)

Set the query part of the URL

Parameters
QueryString | string | array$queryQuery to set
Returns
Url

Definition at line 428 of file Url.php.

References Guzzle\Http\Url\$query.

Referenced by Guzzle\Http\Url\__construct().

◆ setScheme()

Guzzle\Http\Url::setScheme (   $scheme)

Set the scheme part of the URL (http, https, ftp, etc)

Parameters
string$schemeScheme to set
Returns
Url

Definition at line 217 of file Url.php.

References Guzzle\Http\Url\$scheme.

◆ setUsername()

Guzzle\Http\Url::setUsername (   $username)

Set the username part of the URL

Parameters
string$usernameUsername to set
Returns
Url

Definition at line 394 of file Url.php.

References Guzzle\Http\Url\$username.

Field Documentation

◆ $fragment

Guzzle\Http\Url::$fragment
protected

◆ $host

Guzzle\Http\Url::$host
protected

◆ $password

Guzzle\Http\Url::$password
protected

◆ $path

Guzzle\Http\Url::$path = ''
protected

◆ $port

Guzzle\Http\Url::$port
protected

◆ $query

◆ $scheme

Guzzle\Http\Url::$scheme
protected

◆ $username

Guzzle\Http\Url::$username
protected

The documentation for this class was generated from the following file: