PHP Class Elastica\Param

This function can be used to handle params for queries, filter
Author: Nicolas Ruflin ([email protected])
Inheritance: implements elastica\ArrayableInterface
显示文件 Open project: ruflin/elastica Class Usage Examples

Protected Properties

Property Type Description
$_params array Params.
$_rawParams array Raw Params.

Public Methods

Method Description
addParam ( string $key, mixed $value ) Adds a param to the list.
getParam ( string $key ) : mixed Returns a specific param.
getParams ( ) : array Returns the params array.
hasParam ( string $key ) : boolean Test if a param is set.
setParam ( string $key, mixed $value ) Sets (overwrites) the value at the given key.
setParams ( array $params ) Sets (overwrites) all params of this object.
toArray ( ) : array Converts the params to an array. A default implementation exist to create the an array out of the class name (last part of the class name) and the params.

Protected Methods

Method Description
_convertArrayable ( array $array ) : array Cast objects to arrays.
_getBaseName ( ) : string Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.
_setRawParam ( string $key, mixed $value ) Sets params not inside params array.

Method Details

_convertArrayable() protected method

Cast objects to arrays.
protected _convertArrayable ( array $array ) : array
$array array
return array

_getBaseName() protected method

Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.
protected _getBaseName ( ) : string
return string name

_setRawParam() protected method

Sets params not inside params array.
protected _setRawParam ( string $key, mixed $value )
$key string
$value mixed

addParam() public method

This function can be used to add an array of params
public addParam ( string $key, mixed $value )
$key string Param key
$value mixed Value to set

getParam() public method

Returns a specific param.
public getParam ( string $key ) : mixed
$key string Key to return
return mixed Key value

getParams() public method

Returns the params array.
public getParams ( ) : array
return array Params

hasParam() public method

Test if a param is set.
public hasParam ( string $key ) : boolean
$key string Key to test
return boolean True if the param is set, false otherwise

setParam() public method

Sets (overwrites) the value at the given key.
public setParam ( string $key, mixed $value )
$key string Key to set
$value mixed Key Value

setParams() public method

Sets (overwrites) all params of this object.
public setParams ( array $params )
$params array Parameter list

toArray() public method

Converts the params to an array. A default implementation exist to create the an array out of the class name (last part of the class name) and the params.
public toArray ( ) : array
return array Filter array

Property Details

$_params protected_oe property

Params.
protected array $_params
return array

$_rawParams protected_oe property

Raw Params.
protected array $_rawParams
return array