Merge pull request #5226 from davecivicrm/CRM-15578
[civicrm-core.git] / CRM / Utils / QueryFormatter.php
index cc3a382748b1803b2683850149f2fba9ecd75cd7..14694b1cf2dfd7c3580b0efc5ccad75a7c836c85 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
@@ -24,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * Class CRM_Utils_QueryFormatter
@@ -89,7 +88,8 @@ class CRM_Utils_QueryFormatter {
   protected $mode;
 
   /**
-   * @param string $mode eg MODE_NONE
+   * @param string $mode
+   *   Eg MODE_NONE.
    */
   public function __construct($mode) {
     $this->mode = $mode;
@@ -111,7 +111,8 @@ class CRM_Utils_QueryFormatter {
 
   /**
    * @param string $text
-   * @param string $language eg LANG_SQL_LIKE, LANG_SQL_FTS, LANG_SOLR
+   * @param string $language
+   *   Eg LANG_SQL_LIKE, LANG_SQL_FTS, LANG_SOLR.
    * @throws CRM_Core_Exception
    * @return string
    */
@@ -123,12 +124,15 @@ class CRM_Utils_QueryFormatter {
       case self::LANG_SQL_FTS:
         $text = $this->_formatFts($text, $this->mode);
         break;
+
       case self::LANG_SQL_FTSBOOL:
         $text = $this->_formatFtsBool($text, $this->mode);
         break;
+
       case self::LANG_SQL_LIKE:
         $text = $this->_formatLike($text, $this->mode);
         break;
+
       default:
         $text = NULL;
     }
@@ -140,6 +144,14 @@ class CRM_Utils_QueryFormatter {
     return $text;
   }
 
+  /**
+   * Format Fts.
+   *
+   * @param string $text
+   * @param $mode
+   *
+   * @return mixed
+   */
   protected function _formatFts($text, $mode) {
     $result = NULL;
 
@@ -183,6 +195,14 @@ class CRM_Utils_QueryFormatter {
     return $this->dedupeWildcards($result, '%');
   }
 
+  /**
+   * Format FTS.
+   *
+   * @param string $text
+   * @param $mode
+   *
+   * @return mixed
+   */
   protected function _formatFtsBool($text, $mode) {
     $result = NULL;
 
@@ -234,6 +254,14 @@ class CRM_Utils_QueryFormatter {
     return $this->dedupeWildcards($result, '%');
   }
 
+  /**
+   * Format like.
+   *
+   * @param $text
+   * @param $mode
+   *
+   * @return mixed
+   */
   protected function _formatLike($text, $mode) {
     $result = NULL;
 
@@ -266,8 +294,10 @@ class CRM_Utils_QueryFormatter {
   }
 
   /**
-   * @param string $text user-supplied query string
-   * @param string $template a prototypical description of each word, eg "word%" or "word*" or "*word*"
+   * @param string $text
+   *   User-supplied query string.
+   * @param string $template
+   *   A prototypical description of each word, eg "word%" or "word*" or "*word*".
    * @return string
    */
   protected function mapWords($text, $template) {
@@ -303,6 +333,11 @@ class CRM_Utils_QueryFormatter {
     return $text;
   }
 
+  /**
+   * Get modes.
+   *
+   * @return array
+   */
   public static function getModes() {
     return array(
       self::MODE_NONE,
@@ -313,6 +348,11 @@ class CRM_Utils_QueryFormatter {
     );
   }
 
+  /**
+   * Get languages.
+   *
+   * @return array
+   */
   public static function getLanguages() {
     return array(
       self::LANG_SOLR,
@@ -348,4 +388,5 @@ class CRM_Utils_QueryFormatter {
 
     echo $buf;
   }
+
 }