PHP Class Nathanmac\Utilities\Parser\Parser

Author: Nathan Macnamara ([email protected])
Datei anzeigen Open project: nathanmac/parser Class Usage Examples

Public Methods

Method Description
all ( ) : array Alias to the payload function.
bson ( $payload ) : array BSON parser, helper function.
except ( string | array $keys ) : array Get all of the input except for a specified array of items.
get ( string $key = null, string $default = null ) : mixed | null Retrieve an payload item from the payload data, return default item if item not found.
getFormatClass ( $format = '' ) : string Autodetect the payload data type using content-type value.
has ( string | array $keys ) : boolean Determine if the payload contains a non-empty value for a given key.
json ( $payload ) : array JSON parser, helper function.
mask ( array $mask ) : array Mask input data with a given mapping.
msgpack ( $payload ) : array MSGPack parser, helper function.
only ( string | array $keys ) : array Get a subset of the items from the payload data.
parse ( string $payload, Nathanmac\Utilities\Parser\Formats\FormatInterface $format ) : array Parse payload string using given formatter.
payload ( string $format = '' ) : array Parse the HTTP payload data, autodetect format and return all data in array.
querystr ( $payload ) : array Query String parser, helper function.
registerFormat ( $format, $class ) : self Register Format Class.
serialize ( $payload ) : array Serialized Data parser, helper function.
xml ( $payload ) : array XML parser, helper function.
yaml ( $payload ) : array YAML parser, helper function.

Protected Methods

Method Description
getPayload ( ) : string Return the payload data from the HTTP post request.

Private Methods

Method Description
buildArray ( $route, null $data = null ) : array | null Build the array structure for value.
getValueAtKey ( $key, $data ) : mixed Return a value from the array identified from the key.
hasValueAtKey ( $key, $data ) : boolean Array contains a value identified from the key, returns bool
processContentType ( string $contentType ) : boolean | string Process the content-type values
processMask ( array $mask ) : string Recursive processor for processing user masks.
removeValue ( &$array, $key ) Remove a value identified from the key

Method Details

all() public method

Alias to the payload function.
public all ( ) : array
return array

bson() public method

BSON parser, helper function.
public bson ( $payload ) : array
$payload
return array

except() public method

Get all of the input except for a specified array of items.
public except ( string | array $keys ) : array
$keys string | array
return array

get() public method

Retrieve an payload item from the payload data, return default item if item not found.
public get ( string $key = null, string $default = null ) : mixed | null
$key string
$default string
return mixed | null

getFormatClass() public method

Autodetect the payload data type using content-type value.
public getFormatClass ( $format = '' ) : string
return string Return the name of the formatter class.

getPayload() protected method

Return the payload data from the HTTP post request.
protected getPayload ( ) : string
return string

has() public method

Determine if the payload contains a non-empty value for a given key.
public has ( string | array $keys ) : boolean
$keys string | array
return boolean

json() public method

JSON parser, helper function.
public json ( $payload ) : array
$payload
return array

mask() public method

Mask input data with a given mapping.
public mask ( array $mask ) : array
$mask array
return array

msgpack() public method

MSGPack parser, helper function.
public msgpack ( $payload ) : array
$payload
return array

only() public method

Get a subset of the items from the payload data.
public only ( string | array $keys ) : array
$keys string | array
return array

parse() public method

Parse payload string using given formatter.
public parse ( string $payload, Nathanmac\Utilities\Parser\Formats\FormatInterface $format ) : array
$payload string
$format Nathanmac\Utilities\Parser\Formats\FormatInterface
return array

payload() public method

Override the format by providing a content type.
public payload ( string $format = '' ) : array
$format string
return array

querystr() public method

Query String parser, helper function.
public querystr ( $payload ) : array
$payload
return array

registerFormat() public method

Register Format Class.
public registerFormat ( $format, $class ) : self
$format
$class
return self

serialize() public method

Serialized Data parser, helper function.
public serialize ( $payload ) : array
$payload
return array

xml() public method

XML parser, helper function.
public xml ( $payload ) : array
$payload
return array

yaml() public method

YAML parser, helper function.
public yaml ( $payload ) : array
$payload
return array