PHP Класс Base

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__call ( $key, $args ) : mixed Call function identified by hive key
__construct ( ) ! Bootstrap
__get ( $key ) : mixed Alias for offsetget()
__isset ( $key ) : mixed Alias for offsetexists()
__set ( $key, $val ) : mixed Alias for offsetset()
__unset ( $key ) : mixed Alias for offsetunset()
abort ( ) Disconnect HTTP client
agent ( ) : string Return HTTP user agent
ajax ( ) : boolean Return TRUE if XMLHttpRequest detected
alias ( $name, $params = [], $query = NULL ) : string Assemble url from alias name
base64 ( $data, $mime ) : string Return Base64-encoded equivalent
blacklisted ( $ip ) : boolean Return TRUE if IPv4 address exists in DNSBL
build ( $url, $args = [] ) : string Replace tokenized URL with available token values
call ( $func, $args = NULL, $hooks = '' ) : mixed | FALSE Execute callback/hooks (supports 'class->method' format)
camelcase ( $str ) : string Convert snakecase string to camelcase
chain ( $funcs, $args = NULL ) : array Execute specified callbacks in succession; Apply same arguments to all callbacks
checked ( $key ) : boolean Return TRUE if hive variable is 'on'
clean ( $arg, $tags = NULL ) : mixed Remove HTML tags (except those enumerated) and non-printable characters to mitigate XSS/code injection attacks
clear ( $key ) : null Unset hive key
compile ( $str ) : string Convert JS-style token to PHP expression
concat ( $key, $val ) : string Concatenate string to hive string variable
config ( $file, $allow = FALSE ) : object Configure framework according to .ini-style file settings; If optional 2nd arg is provided, template strings are interpreted
constants ( $class, $prefix = '' ) : array Convert class constants to array
copy ( $src, $dst ) : mixed Copy contents of hive variable to another
csv ( array $args ) : string Flatten array values and return as CSV string
decode ( $str ) : string Convert HTML entities back to characters
devoid ( $key, &$val = NULL ) : boolean Return TRUE if hive key is empty and not cached
dump ( $expr ) : null Dump expression with syntax highlighting
encode ( $str ) : string Convert special characters to HTML entities
error ( $code, $text = '', array $trace = NULL, $level ) : null Log error; Execute ONERROR handler if defined, else display default error page (HTML for synchronous requests, JSON string for AJAX requests)
exists ( $key, &$val = NULL ) : boolean Return TRUE if hive key is set (or return timestamp and TTL if cached)
expire ( $secs ) : null Send cache metadata to HTTP client
extend ( $key, $src, $keep = FALSE ) : array Extend hive array variable with default values from $src
extract ( $arr, $prefix ) : array Extract values of array whose keys start with the given prefix
fixslashes ( $str ) : string Convert backslashes to slashes
flip ( $key ) : array Swap keys and values of hive array variable
format ( ) : string Return locale-aware formatted string
get ( $key, $args = NULL ) : mixed Retrieve contents of hive key
grab ( $func, $args = NULL ) : string | array Grab the real route handler behind the string expression
hash ( $str ) : string Generate 64bit/base36 hash
highlight ( $text ) : string Apply syntax highlighting
hive ( ) : array Publish hive contents
ip ( ) : string Sniff IP address
language ( $code ) : string Assign/auto-detect language
lexicon ( $path, $ttl ) : array Return lexicon entries
map ( $url, $class, $ttl, $kbps ) : null Provide ReST interface by mapping HTTP verb to class method
mask ( $pattern, $url = NULL ) Applies the specified URL mask and returns parameterized matches
merge ( $key, $src, $keep = FALSE ) : array Merge array with hive array variable
mock ( $pattern, array $args = NULL, array $headers = NULL, $body = NULL ) : mixed Mock HTTP request
mset ( array $vars, $prefix = '', $ttl ) : null Multi-variable assignment using associative array
mutex ( $id, $func, $args = NULL ) : mixed Create mutex, invoke callback then drop ownership when done
offsetexists ( $key ) : mixed Convenience method for checking hive key
offsetget ( $key ) : mixed Convenience method for retrieving hive value
offsetset ( $key, $val ) : mixed Convenience method for assigning hive value
offsetunset ( $key ) : null Convenience method for removing hive key
parse ( $str ) : array Parse string containing key-value pairs
pop ( $key ) : mixed Remove last element of hive array variable
push ( $key, $val ) : mixed Add element to the end of hive array variable
read ( $file, $lf = FALSE ) : string Read file (with option to apply Unix LF as standard line ending)
recursive ( $arg, $func, $stack = [] ) : mixed Invoke callback recursively for all data types
redirect ( $pattern, $url, $permanent = TRUE ) : null Redirect a route to another URL
ref ( $key, $add = TRUE, &$var = NULL ) : mixed Get hive key reference/contents; Add non-existent hive keys, array elements, and object properties by default
rel ( $url ) : string Return path (and query parameters) relative to the base directory
relay ( $funcs, $args = NULL ) : array Execute specified callbacks in succession; Relay result of previous callback as argument to the next callback
reroute ( $url = NULL, $permanent = FALSE ) : null Reroute to specified URI
route ( $pattern, $handler, $ttl, $kbps ) : null Bind handler to route pattern
run ( ) : mixed Match routes against incoming URI
scrub ( &$var, $tags = NULL ) : mixed Similar to clean(), except that variable is passed by reference
serialize ( $arg ) : string Return string representation of PHP value
set ( $key, $val, $ttl ) : mixed Bind value to hive key
shift ( $key ) : mixed Remove first element of hive array variable
sign ( $num ) : integer Return -1 if specified number is negative, 0 if zero, or 1 if the number is positive
snakecase ( $str ) : string Convert camelcase string to snakecase
split ( $str, $noempty = TRUE ) : array Split comma-, semi-colon, or pipe-separated string
status ( $code ) : string Send HTTP status header; Return text equivalent of status code
stringify ( $arg, array $stack = NULL ) : string Convert PHP expression/value to compressed exportable string
sync ( $key ) : array Sync PHP global with corresponding hive key
trace ( array $trace = NULL, $format = TRUE ) : string | array Return filtered stack trace as a formatted string (or array)
unload ( $cwd ) Execute framework/application shutdown sequence
unserialize ( $arg ) : string Return PHP value derived from string
unshift ( $key, $val ) : mixed Add element to the beginning of hive array variable
until ( $func, $args = NULL, $timeout = 60 ) : mixed Loop until callback returns TRUE (for long polling)
visible ( $obj, $key ) : boolean Return TRUE if property has public visibility
write ( $file, $data, $append = FALSE ) : integer | FALSE Exclusive file write

Защищенные методы

Метод Описание
autoload ( $class ) : mixed Namespace-aware class autoloader

Приватные методы

Метод Описание
__clone ( ) ! Prohibit cloning
cut ( $key ) : array Return the parts of specified hive key

Описание методов

__call() публичный Метод

Call function identified by hive key
public __call ( $key, $args ) : mixed
$key string
$args array
Результат mixed

__construct() публичный Метод

! Bootstrap
public __construct ( )

__get() публичный Метод

Alias for offsetget()
public __get ( $key ) : mixed
$key string
Результат mixed

__isset() публичный Метод

Alias for offsetexists()
public __isset ( $key ) : mixed
$key string
Результат mixed

__set() публичный Метод

Alias for offsetset()
public __set ( $key, $val ) : mixed
$key string
$val mixed
Результат mixed

__unset() публичный Метод

Alias for offsetunset()
public __unset ( $key ) : mixed
$key string
Результат mixed

abort() публичный Метод

Disconnect HTTP client
public abort ( )

agent() публичный Метод

Return HTTP user agent
public agent ( ) : string
Результат string

ajax() публичный Метод

Return TRUE if XMLHttpRequest detected
public ajax ( ) : boolean
Результат boolean

alias() публичный Метод

Assemble url from alias name
public alias ( $name, $params = [], $query = NULL ) : string
$name string
$params array|string
$query string|array
Результат string

autoload() защищенный Метод

Namespace-aware class autoloader
protected autoload ( $class ) : mixed
$class string
Результат mixed

base64() публичный Метод

Return Base64-encoded equivalent
public base64 ( $data, $mime ) : string
$data string
$mime string
Результат string

blacklisted() публичный Метод

Return TRUE if IPv4 address exists in DNSBL
public blacklisted ( $ip ) : boolean
$ip string
Результат boolean

build() публичный Метод

Replace tokenized URL with available token values
public build ( $url, $args = [] ) : string
$url array|string
$args array
Результат string

call() публичный Метод

Execute callback/hooks (supports 'class->method' format)
public call ( $func, $args = NULL, $hooks = '' ) : mixed | FALSE
$func callback
$args mixed
$hooks string
Результат mixed | FALSE

camelcase() публичный Метод

Convert snakecase string to camelcase
public camelcase ( $str ) : string
$str string
Результат string

chain() публичный Метод

Execute specified callbacks in succession; Apply same arguments to all callbacks
public chain ( $funcs, $args = NULL ) : array
$funcs array|string
$args mixed
Результат array

checked() публичный Метод

Return TRUE if hive variable is 'on'
public checked ( $key ) : boolean
$key string
Результат boolean

clean() публичный Метод

Remove HTML tags (except those enumerated) and non-printable characters to mitigate XSS/code injection attacks
public clean ( $arg, $tags = NULL ) : mixed
$arg mixed
$tags string
Результат mixed

clear() публичный Метод

Unset hive key
public clear ( $key ) : null
$key string
Результат null

compile() публичный Метод

Convert JS-style token to PHP expression
public compile ( $str ) : string
$str string
Результат string

concat() публичный Метод

Concatenate string to hive string variable
public concat ( $key, $val ) : string
$key string
$val string
Результат string

config() публичный Метод

Configure framework according to .ini-style file settings; If optional 2nd arg is provided, template strings are interpreted
public config ( $file, $allow = FALSE ) : object
$file string
$allow bool
Результат object

constants() публичный Метод

Convert class constants to array
public constants ( $class, $prefix = '' ) : array
$class object|string
$prefix string
Результат array

copy() публичный Метод

Copy contents of hive variable to another
public copy ( $src, $dst ) : mixed
$src string
$dst string
Результат mixed

csv() публичный Метод

Flatten array values and return as CSV string
public csv ( array $args ) : string
$args array array
Результат string

decode() публичный Метод

Convert HTML entities back to characters
public decode ( $str ) : string
$str string
Результат string

devoid() публичный Метод

Return TRUE if hive key is empty and not cached
public devoid ( $key, &$val = NULL ) : boolean
$key string
$val mixed
Результат boolean

dump() публичный Метод

Dump expression with syntax highlighting
public dump ( $expr ) : null
$expr mixed
Результат null

encode() публичный Метод

Convert special characters to HTML entities
public encode ( $str ) : string
$str string
Результат string

error() публичный Метод

Log error; Execute ONERROR handler if defined, else display default error page (HTML for synchronous requests, JSON string for AJAX requests)
public error ( $code, $text = '', array $trace = NULL, $level ) : null
$code int
$text string
$trace array array
$level int
Результат null

exists() публичный Метод

Return TRUE if hive key is set (or return timestamp and TTL if cached)
public exists ( $key, &$val = NULL ) : boolean
$key string
$val mixed
Результат boolean

expire() публичный Метод

Send cache metadata to HTTP client
public expire ( $secs ) : null
$secs int
Результат null

extend() публичный Метод

Extend hive array variable with default values from $src
public extend ( $key, $src, $keep = FALSE ) : array
$key string
$src string|array
$keep bool
Результат array

extract() публичный Метод

Extract values of array whose keys start with the given prefix
public extract ( $arr, $prefix ) : array
$arr array
$prefix string
Результат array

fixslashes() публичный Метод

Convert backslashes to slashes
public fixslashes ( $str ) : string
$str string
Результат string

flip() публичный Метод

Swap keys and values of hive array variable
public flip ( $key ) : array
$key string
Результат array

format() публичный Метод

Return locale-aware formatted string
public format ( ) : string
Результат string

get() публичный Метод

Retrieve contents of hive key
public get ( $key, $args = NULL ) : mixed
$key string
$args string|array
Результат mixed

grab() публичный Метод

Grab the real route handler behind the string expression
public grab ( $func, $args = NULL ) : string | array
$func string
$args array
Результат string | array

hash() публичный Метод

Generate 64bit/base36 hash
public hash ( $str ) : string
$str
Результат string

highlight() публичный Метод

Apply syntax highlighting
public highlight ( $text ) : string
$text string
Результат string

hive() публичный Метод

Publish hive contents
public hive ( ) : array
Результат array

ip() публичный Метод

Sniff IP address
public ip ( ) : string
Результат string

language() публичный Метод

Assign/auto-detect language
public language ( $code ) : string
$code string
Результат string

lexicon() публичный Метод

Return lexicon entries
public lexicon ( $path, $ttl ) : array
$path string
$ttl int
Результат array

map() публичный Метод

Provide ReST interface by mapping HTTP verb to class method
public map ( $url, $class, $ttl, $kbps ) : null
$url string
$class string|object
$ttl int
$kbps int
Результат null

mask() публичный Метод

Applies the specified URL mask and returns parameterized matches
public mask ( $pattern, $url = NULL )
$pattern string
$url string|NULL

merge() публичный Метод

Merge array with hive array variable
public merge ( $key, $src, $keep = FALSE ) : array
$key string
$src string|array
$keep bool
Результат array

mock() публичный Метод

Mock HTTP request
public mock ( $pattern, array $args = NULL, array $headers = NULL, $body = NULL ) : mixed
$pattern string
$args array array
$headers array array
$body string
Результат mixed

mset() публичный Метод

Multi-variable assignment using associative array
public mset ( array $vars, $prefix = '', $ttl ) : null
$vars array array
$prefix string
$ttl int
Результат null

mutex() публичный Метод

Create mutex, invoke callback then drop ownership when done
public mutex ( $id, $func, $args = NULL ) : mixed
$id string
$func callback
$args mixed
Результат mixed

offsetexists() публичный Метод

Convenience method for checking hive key
public offsetexists ( $key ) : mixed
$key string
Результат mixed

offsetget() публичный Метод

Convenience method for retrieving hive value
public offsetget ( $key ) : mixed
$key string
Результат mixed

offsetset() публичный Метод

Convenience method for assigning hive value
public offsetset ( $key, $val ) : mixed
$key string
$val scalar
Результат mixed

offsetunset() публичный Метод

Convenience method for removing hive key
public offsetunset ( $key ) : null
$key string
Результат null

parse() публичный Метод

Parse string containing key-value pairs
public parse ( $str ) : array
$str string
Результат array

pop() публичный Метод

Remove last element of hive array variable
public pop ( $key ) : mixed
$key string
Результат mixed

push() публичный Метод

Add element to the end of hive array variable
public push ( $key, $val ) : mixed
$key string
$val mixed
Результат mixed

read() публичный Метод

Read file (with option to apply Unix LF as standard line ending)
public read ( $file, $lf = FALSE ) : string
$file string
$lf bool
Результат string

recursive() публичный Метод

Invoke callback recursively for all data types
public recursive ( $arg, $func, $stack = [] ) : mixed
$arg mixed
$func callback
$stack array
Результат mixed

redirect() публичный Метод

Redirect a route to another URL
public redirect ( $pattern, $url, $permanent = TRUE ) : null
$pattern string|array
$url string
$permanent bool
Результат null

ref() публичный Метод

Get hive key reference/contents; Add non-existent hive keys, array elements, and object properties by default
public ref ( $key, $add = TRUE, &$var = NULL ) : mixed
$key string
$add bool
$var mixed
Результат mixed

rel() публичный Метод

Return path (and query parameters) relative to the base directory
public rel ( $url ) : string
$url string
Результат string

relay() публичный Метод

Execute specified callbacks in succession; Relay result of previous callback as argument to the next callback
public relay ( $funcs, $args = NULL ) : array
$funcs array|string
$args mixed
Результат array

reroute() публичный Метод

Reroute to specified URI
public reroute ( $url = NULL, $permanent = FALSE ) : null
$url array|string
$permanent bool
Результат null

route() публичный Метод

Bind handler to route pattern
public route ( $pattern, $handler, $ttl, $kbps ) : null
$pattern string|array
$handler callback
$ttl int
$kbps int
Результат null

run() публичный Метод

Match routes against incoming URI
public run ( ) : mixed
Результат mixed

scrub() публичный Метод

Similar to clean(), except that variable is passed by reference
public scrub ( &$var, $tags = NULL ) : mixed
$var mixed
$tags string
Результат mixed

serialize() публичный Метод

Return string representation of PHP value
public serialize ( $arg ) : string
$arg mixed
Результат string

set() публичный Метод

Bind value to hive key
public set ( $key, $val, $ttl ) : mixed
$key string
$val mixed
$ttl int
Результат mixed

shift() публичный Метод

Remove first element of hive array variable
public shift ( $key ) : mixed
$key string
Результат mixed

sign() публичный Метод

Return -1 if specified number is negative, 0 if zero, or 1 if the number is positive
public sign ( $num ) : integer
$num mixed
Результат integer

snakecase() публичный Метод

Convert camelcase string to snakecase
public snakecase ( $str ) : string
$str string
Результат string

split() публичный Метод

Split comma-, semi-colon, or pipe-separated string
public split ( $str, $noempty = TRUE ) : array
$str string
$noempty bool
Результат array

status() публичный Метод

Send HTTP status header; Return text equivalent of status code
public status ( $code ) : string
$code int
Результат string

stringify() публичный Метод

Convert PHP expression/value to compressed exportable string
public stringify ( $arg, array $stack = NULL ) : string
$arg mixed
$stack array array
Результат string

sync() публичный Метод

Sync PHP global with corresponding hive key
public sync ( $key ) : array
$key string
Результат array

trace() публичный Метод

Return filtered stack trace as a formatted string (or array)
public trace ( array $trace = NULL, $format = TRUE ) : string | array
$trace array array|NULL
$format bool
Результат string | array

unload() публичный Метод

Execute framework/application shutdown sequence
public unload ( $cwd )
$cwd string

unserialize() публичный Метод

Return PHP value derived from string
public unserialize ( $arg ) : string
$arg mixed
Результат string

unshift() публичный Метод

Add element to the beginning of hive array variable
public unshift ( $key, $val ) : mixed
$key string
$val mixed
Результат mixed

until() публичный Метод

Loop until callback returns TRUE (for long polling)
public until ( $func, $args = NULL, $timeout = 60 ) : mixed
$func callback
$args array
$timeout int
Результат mixed

visible() публичный Метод

Return TRUE if property has public visibility
public visible ( $obj, $key ) : boolean
$obj object
$key string
Результат boolean

write() публичный Метод

Exclusive file write
public write ( $file, $data, $append = FALSE ) : integer | FALSE
$file string
$data mixed
$append bool
Результат integer | FALSE