PHP Class Elastica\Util

Author: Nicolas Ruflin ([email protected])
Author: Thibault Duplessis ([email protected])
Author: Oleg Zinchenko ([email protected])
Author: Roberto Nygaard ([email protected])
显示文件 Open project: ruflin/elastica Class Usage Examples

Public Methods

Method Description
convertDate ( integer | string $date ) : string Converts given time to format: 1995-12-31T23:59:59Z.
convertDateTimeObject ( DateTime $dateTime, boolean $includeTimezone = true ) : string Convert a \DateTime object to format: 1995-12-31T23:59:59Z+02:00.
convertRequestToCurlCommand ( Request $request ) : string Converts Request to Curl console command.
escapeTerm ( string $term ) : string Escapes the following terms (because part of the query language) + - && || ! ( ) { } [ ] ^ " ~ * ? : \ < >.
getParamName ( $class ) : string Tries to guess the name of the param, based on its class Example: \Elastica\Filter\HasChildFilter => has_child.
replaceBooleanWords ( string $term ) : string Replace the following reserved words (because part of the query language) AND OR NOT.
replaceBooleanWordsAndEscapeTerm ( string $term ) : string Replace the following reserved words: AND OR NOT and escapes the following terms: + - && || ! ( ) { } [ ] ^ " ~ * ? : \.
toCamelCase ( string $string ) : string Converts a snake_case string to CamelCase.
toSnakeCase ( string $string ) : string Converts a CamelCase string to snake_case.

Method Details

convertDate() public static method

This is the lucene date format
public static convertDate ( integer | string $date ) : string
$date integer | string Date input (could be string etc.) -> must be supported by strtotime
return string Converted date string

convertDateTimeObject() public static method

Converts it to the lucene format, including the appropriate TimeZone
public static convertDateTimeObject ( DateTime $dateTime, boolean $includeTimezone = true ) : string
$dateTime DateTime
$includeTimezone boolean
return string

convertRequestToCurlCommand() public static method

Converts Request to Curl console command.
public static convertRequestToCurlCommand ( Request $request ) : string
$request Request
return string

escapeTerm() public static method

Escapes the following terms (because part of the query language) + - && || ! ( ) { } [ ] ^ " ~ * ? : \ < >.
public static escapeTerm ( string $term ) : string
$term string Query term to escape
return string Escaped query term

getParamName() public static method

Tries to guess the name of the param, based on its class Example: \Elastica\Filter\HasChildFilter => has_child.
public static getParamName ( $class ) : string
return string parameter name

replaceBooleanWords() public static method

Replace the following reserved words (because part of the query language) AND OR NOT.
public static replaceBooleanWords ( string $term ) : string
$term string Query term to replace
return string Replaced query term

replaceBooleanWordsAndEscapeTerm() public static method

Replace the following reserved words: AND OR NOT and escapes the following terms: + - && || ! ( ) { } [ ] ^ " ~ * ? : \.
public static replaceBooleanWordsAndEscapeTerm ( string $term ) : string
$term string Query term to replace and escape
return string Replaced and escaped query term

toCamelCase() public static method

For example: hello_world to HelloWorld
public static toCamelCase ( string $string ) : string
$string string snake_case string
return string CamelCase string

toSnakeCase() public static method

For Example HelloWorld to hello_world
public static toSnakeCase ( string $string ) : string
$string string CamelCase String to Convert
return string SnakeCase string