Auth_OpenID
in package
The OpenID utility function class.
Tags
Table of Contents
- addPrefix() : array<string|int, mixed>
- Adds a string prefix to all values of an array. Returns a new array containing the prefixed values.
- appendArgs() : string
- "Appends" query arguments onto a URL. The URL may or may not already have arguments (following a question mark).
- arrayGet() : mixed
- Convenience function for getting array values. Given an array $arr and a key $key, get the corresponding value from the array or return $default if the key is absent.
- autoSubmitHTML() : mixed
- bytes() : int
- Count the number of bytes in a string independently of multibyte support conditions.
- ensureDir() : bool
- Create dir_name as a directory if it does not exist. If it exists, make sure that it is, in fact, a directory. Returns true if the operation succeeded; false if not.
- filter() : mixed
- getQuery() : array<string|int, mixed>
- Gets the query data from the server environment based on the request method used. If GET was used, this looks at $_SERVER['QUERY_STRING'] directly. If POST was used, this fetches data from the special php://input file stream.
- httpBuildQuery() : string
- Implements the PHP 5 'http_build_query' functionality.
- intval() : bool|int
- Replacement (wrapper) for PHP's intval() because it's broken.
- isFailure() : bool
- Return true if $thing is an Auth_OpenID_FailureResponse object; false if not.
- log() : mixed
- Wrap PHP's standard error_log functionality. Use this to perform all logging. It will interpolate any additional arguments into the format string before logging.
- normalizeUrl() : mixed
- Given a URL, this "normalizes" it by adding a trailing slash and / or a leading http:// scheme where necessary. Returns null if the original URL is malformed and cannot be normalized.
- params_from_string() : mixed
- parse_str() : array<string|int, mixed>|null
- Replacement for PHP's broken parse_str.
- toBytes() : array<string|int, mixed>
- Get the bytes in a string independently of multibyte support conditions.
- update() : mixed
- urldefrag() : mixed
- urlunparse() : string
- Implements python's urlunparse, which is not available in PHP.
Methods
addPrefix()
Adds a string prefix to all values of an array. Returns a new array containing the prefixed values.
public
static addPrefix(array<string|int, mixed> $values, string $prefix) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
- $prefix : string
Tags
Return values
array<string|int, mixed> —appendArgs()
"Appends" query arguments onto a URL. The URL may or may not already have arguments (following a question mark).
public
static appendArgs(string $url, array<string|int, mixed> $args) : string
Parameters
- $url : string
-
A URL, which may or may not already have arguments.
- $args : array<string|int, mixed>
-
Either an array key/value pairs or an array of arrays, each of which holding two values: a key and a value, sequentially. If $args is an ordinary key/value array, the parameters will be added to the URL in sorted alphabetical order; if $args is an array of arrays, their order will be preserved.
Tags
Return values
string —$url The original URL with the new parameters added.
arrayGet()
Convenience function for getting array values. Given an array $arr and a key $key, get the corresponding value from the array or return $default if the key is absent.
public
static arrayGet(array<string|int, mixed> $arr, string $key[, mixed $fallback = null ]) : mixed
Parameters
- $arr : array<string|int, mixed>
- $key : string
- $fallback : mixed = null
Tags
Return values
mixed —autoSubmitHTML()
public
static autoSubmitHTML(mixed $form[, mixed $title = "OpenId transaction in progress" ]) : mixed
Parameters
- $form : mixed
- $title : mixed = "OpenId transaction in progress"
Return values
mixed —bytes()
Count the number of bytes in a string independently of multibyte support conditions.
public
static bytes(string $str) : int
Parameters
- $str : string
-
The string of bytes to count.
Return values
int —The number of bytes in $str.
ensureDir()
Create dir_name as a directory if it does not exist. If it exists, make sure that it is, in fact, a directory. Returns true if the operation succeeded; false if not.
public
static ensureDir(string $dir_name) : bool
Parameters
- $dir_name : string
Tags
Return values
bool —filter()
public
static filter(mixed $callback, mixed &$sequence) : mixed
Parameters
- $callback : mixed
- $sequence : mixed
Return values
mixed —getQuery()
Gets the query data from the server environment based on the request method used. If GET was used, this looks at $_SERVER['QUERY_STRING'] directly. If POST was used, this fetches data from the special php://input file stream.
public
static getQuery([string|null $query_str = null ]) : array<string|int, mixed>
Returns an associative array of the query arguments.
Skips invalid key/value pairs (i.e. keys with no '=value' portion).
Returns an empty array if neither GET nor POST was used, or if POST was used but php://input cannot be opened.
See background: http://lists.openidenabled.com/pipermail/dev/2007-March/000395.html
Parameters
- $query_str : string|null = null
Tags
Return values
array<string|int, mixed> —httpBuildQuery()
Implements the PHP 5 'http_build_query' functionality.
public
static httpBuildQuery(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
-
Either an array key/value pairs or an array of arrays, each of which holding two values: a key and a value, sequentially.
Tags
Return values
string —$result The result of url-encoding the key/value pairs from $data into a URL query string (e.g. "username=bob&id=56").
intval()
Replacement (wrapper) for PHP's intval() because it's broken.
public
static intval(string|int $value) : bool|int
Parameters
- $value : string|int
Tags
Return values
bool|int —isFailure()
Return true if $thing is an Auth_OpenID_FailureResponse object; false if not.
public
static isFailure(object|string $thing) : bool
Parameters
- $thing : object|string
Tags
Return values
bool —log()
Wrap PHP's standard error_log functionality. Use this to perform all logging. It will interpolate any additional arguments into the format string before logging.
public
static log(string $format_string) : mixed
Parameters
- $format_string : string
-
The sprintf format for the message
Return values
mixed —normalizeUrl()
Given a URL, this "normalizes" it by adding a trailing slash and / or a leading http:// scheme where necessary. Returns null if the original URL is malformed and cannot be normalized.
public
static normalizeUrl(string $url) : mixed
Parameters
- $url : string
-
The URL to be normalized.
Tags
Return values
mixed —$new_url The URL after normalization, or null if $url was malformed.
params_from_string()
public
static params_from_string(mixed $str) : mixed
Parameters
- $str : mixed
Return values
mixed —parse_str()
Replacement for PHP's broken parse_str.
public
static parse_str(string|null $query) : array<string|int, mixed>|null
Parameters
- $query : string|null
Return values
array<string|int, mixed>|null —toBytes()
Get the bytes in a string independently of multibyte support conditions.
public
static toBytes(string $str) : array<string|int, mixed>
Parameters
- $str : string
Return values
array<string|int, mixed> —update()
public
static update(mixed &$dest, mixed &$src) : mixed
Parameters
- $dest : mixed
- $src : mixed
Return values
mixed —urldefrag()
public
static urldefrag(mixed $url) : mixed
Parameters
- $url : mixed
Return values
mixed —urlunparse()
Implements python's urlunparse, which is not available in PHP.
public
static urlunparse(string $scheme, string $host[, string $port = null ][, string $path = '/' ][, string $query = '' ][, string $fragment = '' ]) : string
Given the specified components of a URL, this function rebuilds and returns the URL.
Parameters
- $scheme : string
-
The scheme (e.g. 'http'). Defaults to 'http'.
- $host : string
-
The host. Required.
- $port : string = null
-
The port.
- $path : string = '/'
-
The path.
- $query : string = ''
-
The query.
- $fragment : string = ''
-
The fragment.
Tags
Return values
string —$url The URL resulting from assembling the specified components.