IRI parser/serialiser/normaliser

Copyright (c) 2007-2010, Geoffrey Sneddon and Steve Minutillo. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the SimplePie Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package Requests
subpackage Utilities
author Geoffrey Sneddon
author Steve Minutillo
copyright 2007-2009 Geoffrey Sneddon and Steve Minutillo
license http://www.opensource.org/licenses/bsd-license.php
link http://hg.gsnedders.com/iri/

 Methods

Create a new IRI object, from a specified string

__construct(string|null $iri = null

Parameters

$iri

stringnull

Overload __get() to provide access via properties

__get(string $name) : mixed

Parameters

$name

string

Property name

Returns

mixed

Overload __isset() to provide access via properties

__isset(string $name) : boolean

Parameters

$name

string

Property name

Returns

boolean

Overload __set() to provide access via properties

__set(string $name, mixed $value) 

Parameters

$name

string

Property name

$value

mixed

Property value

Return the entire IRI when you try and read the object as a string

__toString() : string

Returns

string

Overload __unset() to provide access via properties

__unset(string $name) 

Parameters

$name

string

Property name

Create a new IRI object by resolving a relative IRI

absolutize(\IRI|string $base, \IRI|string $relative) : \IRI | false
Static

Returns false if $base is not absolute, otherwise an IRI.

Parameters

$base

\IRIstring

(Absolute) Base IRI

$relative

\IRIstring

Relative IRI

Returns

\IRIfalse

Check if the object represents a valid IRI. This needs to be done on each call as some things change depending on another part of the IRI.

is_valid() : boolean

Returns

boolean

Get the complete authority

get_authority() : string

Returns

string

Get the complete iauthority

get_iauthority() : string

Returns

string

Get the complete IRI

get_iri() : string

Returns

string

Get the complete URI

get_uri() : string

Returns

string

Parse an IRI into scheme/authority/path/query/fragment segments

parse_iri(string $iri) : array

Parameters

$iri

string

Returns

array

Remove dot segments from a path

remove_dot_segments(string $input) : string

Parameters

$input

string

Returns

string

Callback function for preg_replace_callback.

remove_iunreserved_percent_encoded(array $match) : string

Removes sequences of percent encoded bytes that represent UTF-8 encoded characters in iunreserved

Parameters

$match

array

PCRE match

Returns

stringReplacement

Replace invalid character with percent encoding

replace_invalid_with_pct_encoding(string $string, string $extra_chars, boolean $iprivate = false) : string

Parameters

$string

string

Input string

$extra_chars

string

Valid characters not in iunreserved or iprivate (this is ASCII-only)

$iprivate

boolean

Allow iprivate

Returns

string

scheme_normalization()

scheme_normalization() 

Set the authority. Returns true on success, false on failure (if there are any invalid characters).

set_authority(string $authority) : boolean

Parameters

$authority

string

Returns

boolean

Set the ifragment.

set_fragment(string $ifragment) : boolean

Parameters

$ifragment

string

Returns

boolean

Set the ihost. Returns true on success, false on failure (if there are any invalid characters).

set_host(string $ihost) : boolean

Parameters

$ihost

string

Returns

boolean

Set the entire IRI. Returns true on success, false on failure (if there are any invalid characters).

set_iri(string $iri) : boolean

Parameters

$iri

string

Returns

boolean

Set the ipath.

set_path(string $ipath) : boolean

Parameters

$ipath

string

Returns

boolean

Set the port. Returns true on success, false on failure (if there are any invalid characters).

set_port(string $port) : boolean

Parameters

$port

string

Returns

boolean

Set the iquery.

set_query(string $iquery) : boolean

Parameters

$iquery

string

Returns

boolean

Set the scheme. Returns true on success, false on failure (if there are any invalid characters).

set_scheme(string $scheme) : boolean

Parameters

$scheme

string

Returns

boolean

Set the iuserinfo.

set_userinfo(string $iuserinfo) : boolean

Parameters

$iuserinfo

string

Returns

boolean

Convert an IRI to a URI (or parts thereof)

to_uri(string | boolean $string) : string | false

Parameters

$string

stringboolean

IRI to convert (or false from {@see get_iri})

Returns

stringfalseURI if IRI is valid, false otherwise.

 Properties

 

Authority part, formatted for a URI (userinfo + host + port)

$authority : string

Default

magic
property Authority part, formatted for a URI (userinfo + host + port)
 

Fragment, formatted for a URI (after '#')

$fragment : string

Default

magic
property Fragment, formatted for a URI (after '#')
 

Host part, formatted for a URI

$host : string

Default

magic
property Host part, formatted for a URI
 

Authority part of the IRI (userinfo + host + port)

$iauthority : string

Default

magic
property Authority part of the IRI (userinfo + host + port)
 

Fragment part of the IRI (after '#')

$ifragment : string

Default

magic
property Fragment part of the IRI (after '#')
 

Host part of the IRI

$ihost : string

Default

magic
property Host part of the IRI
 

Path part of the IRI (after first '/')

$ipath : string

Default

magic
property Path part of the IRI (after first '/')
 

Query part of the IRI (after '?')

$iquery : string

Default

magic
property Query part of the IRI (after '?')
 

IRI we're working with

$iri : string

Default

magic
property IRI we're working with
 

Userinfo part of the IRI (after '://' and before '@')

$iuserinfo : string

Default

magic
property Userinfo part of the IRI (after '://' and before '@')
 

Path part, formatted for a URI (after first '/')

$path : string

Default

magic
property Path part, formatted for a URI (after first '/')
 

Port part of the IRI (after ':')

$port : string

Default

magic
property Port part of the IRI (after ':')
 

Query part, formatted for a URI (after '?')

$query : string

Default

magic
property Query part, formatted for a URI (after '?')
 

Scheme part of the IRI

$scheme : string

Default

magic
property Scheme part of the IRI
 

IRI in URI form, {@see to_uri}

$uri : string

Default

magic
property-read IRI in URI form, {@see to_uri}
 

Userinfo part, formatted for a URI (after '://' and before '@')

$userinfo : string

Default

magic
property Userinfo part, formatted for a URI (after '://' and before '@')
 

ifragment

$ifragment : string

Default

null
 

ihost

$ihost : string

Default

null
 

ipath

$ipath : string

Default

''
 

iquery

$iquery : string

Default

null
 

User Information

$iuserinfo : string

Default

null
 

Normalization database

$normalization 

Default

array('acap' => array('port' => 674), 'dict' => array('port' => 2628), 'file' => array('ihost' => 'localhost'), 'http' => array('port' => 80), 'https' => array('port' => 443))

Each key is the scheme, each value is an array with each key as the IRI part and value as the default value for that part.

 

Port

$port : string

Default

null
 

Scheme

$scheme : string

Default

null