Example #1
0
 public function testToSnakeCase()
 {
     $string = 'HelloWorld';
     $this->assertEquals('hello_world', Elastica_Util::toSnakeCase($string));
     $string = 'HowAreYouToday';
     $this->assertEquals('how_are_you_today', Elastica_Util::toSnakeCase($string));
 }
Example #2
0
 /**
  * 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
  *
  * @return array Filter array
  */
 public function toArray()
 {
     // Picks the last part of the class name and makes it snake_case
     $classNameParts = explode('_', get_class($this));
     $partClassName = Elastica_Util::toSnakeCase(array_pop($classNameParts));
     $data = array($partClassName => $this->getParams());
     if (!empty($this->_rawParams)) {
         $data = array_merge($data, $this->_rawParams);
     }
     return $data;
 }
Example #3
0
 /**
  * Converts given time to format: 1995-12-31T23:59:59Z
  *
  * This is the lucene date format
  *
  * @param int $date Date input (could be string etc.) -> must be supported by strtotime
  * @return string Converted date string
  */
 public function convertDate($date)
 {
     return Elastica_Util::convertDate($date);
 }
Example #4
0
 protected function _getFilterName($filter)
 {
     // Picks the last part of the class name and makes it snake_case
     $classNameParts = explode('_', get_class($filter));
     return Elastica_Util::toSnakeCase(array_pop($classNameParts));
 }
Example #5
0
	/**
	 * 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
	 * 
	 * @return string name
	 */
	protected function _getName() {
		$classNameParts = explode('_', get_class($this));
		$name = Elastica_Util::toSnakeCase(array_pop($classNameParts));
		
		return $name;
	}