INFRA-132 - Cleanup generated dao docblocks
[civicrm-core.git] / CRM / Core / OptionGroup.php
index 3764e9aa187339a4bd424056c16ec7149bc2299b..596450b398456d742896ed6f1e3ec062f351590b 100644 (file)
@@ -36,10 +36,9 @@ class CRM_Core_OptionGroup {
   static $_values = array();
   static $_cache = array();
 
-  /*
+  /**
    * $_domainIDGroups array maintains the list of option groups for whom
    * domainID is to be considered.
-   *
    */
   static $_domainIDGroups = array(
     'from_email_address',
@@ -92,19 +91,28 @@ class CRM_Core_OptionGroup {
    * (radio, select, checkbox etc). OptionGroups for most cases have the
    * 'label' in the label colum and the 'id' or 'name' in the value column
    *
-   * @param $name       string  name of the option group
-   * @param $flip       boolean results are return in id => label format if false
+   * @param string $name
+   *   name of the option group.
+   * @param bool $flip
+   *   results are return in id => label format if false.
    *                            if true, the results are reversed
-   * @param $grouping   boolean if true, return the value in 'grouping' column
-   * @param $localize   boolean if true, localize the results before returning
-   * @param $condition  string  add another condition to the sql query
-   * @param $labelColumnName string the column to use for 'label'
-   * @param $onlyActive boolean return only the action option values
-   * @param $fresh      boolean ignore cache entries and go back to DB
-   * @param $keyColumnName string the column to use for 'key'
+   * @param bool $grouping
+   *   if true, return the value in 'grouping' column.
+   * @param bool $localize
+   *   if true, localize the results before returning.
+   * @param string $condition
+   *   add another condition to the sql query.
+   * @param string $labelColumnName
+   *   the column to use for 'label'.
+   * @param bool $onlyActive
+   *   return only the action option values.
+   * @param bool $fresh
+   *   ignore cache entries and go back to DB.
+   * @param string $keyColumnName
+   *   the column to use for 'key'.
    *
-   * @return array      the values as specified by the above params
-   * @static
+   * @return array
+   *   the values as specified by the above params
    * @void
    */
   static function &values(
@@ -195,21 +203,25 @@ WHERE  v.option_group_id = g.id
    * (radio, select, checkbox etc). OptionGroups for most cases have the
    * 'label' in the label colum and the 'id' or 'name' in the value column
    *
-   * @param $id         integer id of the option group
-   * @param $flip       boolean results are return in id => label format if false
-   *                            if true, the results are reversed
-   * @param $grouping   boolean if true, return the value in 'grouping' column
-   * @param $localize   boolean if true, localize the results before returning
-   * @param $labelColumnName string the column to use for 'label'
-   *
+   * @param int $id
+   *   id of the option group.
+   * @param bool $flip
+   *   results are return in id => label format if false.
+   *   if true, the results are reversed
+   * @param bool $grouping
+   *   if true, return the value in 'grouping' column.
+   * @param bool $localize
+   *   if true, localize the results before returning.
+   * @param string $labelColumnName
+   *   the column to use for 'label'.
    * @param bool $onlyActive
    * @param bool $fresh
    *
-   * @return array      the values as specified by the above params
-   * @static
+   * @return array
+   *   Array of values as specified by the above params
    * @void
    */
-  static function &valuesByID($id, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $labelColumnName = 'label', $onlyActive = TRUE, $fresh = FALSE) {
+  public static function &valuesByID($id, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $labelColumnName = 'label', $onlyActive = TRUE, $fresh = FALSE) {
     $cacheKey = self::createCacheKey($id, $flip, $grouping, $localize, $labelColumnName, $onlyActive);
 
     $cache = CRM_Utils_Cache::singleton();
@@ -246,26 +258,25 @@ WHERE  v.option_group_id = g.id
    * is assigned a new fieldname by id or id's by title
    * (each within a specificied option_group)
    *
-   * @param  array   $params   Reference array of values submitted by the form. Based on
-   *                           $flip, creates new elements in $params for each field in
-   *                           the $names array.
-   *                           If $flip = false, adds     root field name     => title
-   *                           If $flip = true, adds      actual field name   => id
+   * @param array $params
+   *   Reference array of values submitted by the form. Based on.
+   *   $flip, creates new elements in $params for each field in
+   *   the $names array.
+   *   If $flip = false, adds root field name => title
+   *   If $flip = true, adds actual field name => id
    *
-   * @param  array   $names    Reference array of fieldnames we want transformed.
-   *                           Array key = 'postName' (field name submitted by form in $params).
-   *                           Array value = array(
-     'newName' => $newName, 'groupName' => $groupName).
+   * @param array $names
+   *   Reference array of fieldnames we want transformed.
+   *   Array key = 'postName' (field name submitted by form in $params).
+   *   Array value = array('newName' => $newName, 'groupName' => $groupName).
    *
    *
-   * @param  boolean $flip
+   * @param bool $flip
    *
    * @return void
    *
-   * @access public
-   * @static
    */
-  static function lookupValues(&$params, &$names, $flip = FALSE) {
+  public static function lookupValues(&$params, &$names, $flip = FALSE) {
     foreach ($names as $postName => $value) {
       // See if $params field is in $names array (i.e. is a value that we need to lookup)
       if ($postalName = CRM_Utils_Array::value($postName, $params)) {
@@ -290,14 +301,14 @@ WHERE  v.option_group_id = g.id
           }
 
           if ($flip) {
-            $p        = array(1 => array($postValue, 'String'));
+            $p = array(1 => array($postValue, 'String'));
             $lookupBy = 'v.label= %1';
-            $select   = "v.value";
+            $select = "v.value";
           }
           else {
-            $p        = array(1 => array($postValue, 'Integer'));
+            $p = array(1 => array($postValue, 'Integer'));
             $lookupBy = 'v.value = %1';
-            $select   = "v.label";
+            $select = "v.label";
           }
 
           $p[2] = array($value['groupName'], 'String');
@@ -324,7 +335,7 @@ WHERE  v.option_group_id = g.id
    *
    * @return null
    */
-  static function getLabel($groupName, $value, $onlyActiveValue = TRUE) {
+  public static function getLabel($groupName, $value, $onlyActiveValue = TRUE) {
     if (empty($groupName) ||
       empty($value)
     ) {
@@ -343,7 +354,8 @@ WHERE  v.option_group_id = g.id
     if ($onlyActiveValue) {
       $query .= " AND  v.is_active = 1 ";
     }
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+      1 => array($groupName, 'String'),
       2 => array($value, 'Integer'),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
@@ -362,10 +374,11 @@ WHERE  v.option_group_id = g.id
    *
    * @return null
    */
-  static function getValue($groupName,
+  static function getValue(
+    $groupName,
     $label,
     $labelField = 'label',
-    $labelType  = 'String',
+    $labelType = 'String',
     $valueField = 'value'
   ) {
     if (empty($label)) {
@@ -383,7 +396,8 @@ WHERE  v.option_group_id = g.id
   AND  v.$labelField     = %2
 ";
 
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+      1 => array($groupName, 'String'),
       2 => array($label, $labelType),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
@@ -398,14 +412,14 @@ WHERE  v.option_group_id = g.id
   /**
    * Get option_value.value from default option_value row for an option group
    *
-   * @param string $groupName the name of the option group
+   * @param string $groupName
+   *   The name of the option group.
    *
-   * @access public
-   * @static
    *
-   * @return string   the value from the row where is_default = true
+   * @return string
+   *   the value from the row where is_default = true
    */
-  static function getDefaultValue($groupName) {
+  public static function getDefaultValue($groupName) {
     if (empty($groupName)) {
       return NULL;
     }
@@ -432,8 +446,10 @@ WHERE  v.option_group_id = g.id
    * @TODO: Should update the group if it already exists intelligently, so multi-lingual is
    * not messed up. Currently deletes the old group
    *
-   * @param string $groupName the name of the option group - make sure there is no conflict
-   * @param array $values the associative array that has information on the option values
+   * @param string $groupName
+   *   The name of the option group - make sure there is no conflict.
+   * @param array $values
+   *   The associative array that has information on the option values.
    *                          the keys of this array are:
    *                          string 'title'       (required)
    *                          string 'value'       (required)
@@ -442,22 +458,23 @@ WHERE  v.option_group_id = g.id
    *                          int    'weight'      (optional) - the order in which the value are displayed
    *                          bool   'is_default'  (optional) - is this the default one to display when rendered in form
    *                          bool   'is_active'   (optional) - should this element be rendered
-   * @param int $defaultID (reference) - the option value ID of the default element (if set) is returned else 'null'
-   * @param null $groupTitle the optional label of the option group else set to group name
+   * @param int $defaultID
+   *   (reference) - the option value ID of the default element (if set) is returned else 'null'.
+   * @param null $groupTitle
+   *   The optional label of the option group else set to group name.
    *
-   * @access public
-   * @static
    *
-   * @return int   the option group ID
+   * @return int
+   *   the option group ID
    */
-  static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) {
+  public static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) {
     self::deleteAssoc($groupName);
     if (!empty($values)) {
-      $group              = new CRM_Core_DAO_OptionGroup();
-      $group->name        = $groupName;
-      $group->title       = empty($groupTitle) ? $groupName : $groupTitle;
+      $group = new CRM_Core_DAO_OptionGroup();
+      $group->name = $groupName;
+      $group->title = empty($groupTitle) ? $groupName : $groupTitle;
       $group->is_reserved = 1;
-      $group->is_active   = 1;
+      $group->is_active = 1;
       $group->save();
 
       foreach ($values as $v) {
@@ -490,7 +507,7 @@ WHERE  v.option_group_id = g.id
    * @param bool $flip
    * @param string $field
    */
-  static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'name') {
+  public static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'name') {
     $query = "
 SELECT v.id as amount_id, v.value, v.label, v.name, v.description, v.weight
   FROM civicrm_option_group g,
@@ -534,7 +551,7 @@ ORDER BY v.weight
    * @param string $groupName
    * @param string $operator
    */
-  static function deleteAssoc($groupName, $operator = "=") {
+  public static function deleteAssoc($groupName, $operator = "=") {
     $query = "
 DELETE g, v
   FROM civicrm_option_group g,
@@ -553,7 +570,7 @@ DELETE g, v
    *
    * @return null|string
    */
-  static function optionLabel($groupName, $value) {
+  public static function optionLabel($groupName, $value) {
     $query = "
 SELECT v.label
   FROM civicrm_option_group g,
@@ -561,7 +578,8 @@ SELECT v.label
  WHERE g.id = v.option_group_id
    AND g.name  = %1
    AND v.value = %2";
-    $params = array(1 => array($groupName, 'String'),
+    $params = array(
+      1 => array($groupName, 'String'),
       2 => array($value, 'String'),
     );
     return CRM_Core_DAO::singleValueQuery($query, $params);
@@ -576,7 +594,8 @@ SELECT v.label
    *
    * @return array
    */
-  static function getRowValues($groupName, $fieldValue, $field = 'name',
+  static function getRowValues(
+    $groupName, $fieldValue, $field = 'name',
     $fieldType = 'String', $active = TRUE
   ) {
     $query = "
@@ -593,7 +612,8 @@ WHERE  v.option_group_id = g.id
       $query .= " AND  v.is_active = 1";
     }
 
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+      1 => array($groupName, 'String'),
       2 => array($fieldValue, $fieldType),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
@@ -601,14 +621,20 @@ WHERE  v.option_group_id = g.id
 
     if ($dao->fetch()) {
       foreach (array(
-        'id', 'name', 'value', 'label', 'weight', 'description') as $fld) {
+                 'id',
+                 'name',
+                 'value',
+                 'label',
+                 'weight',
+                 'description'
+               ) as $fld) {
         $row[$fld] = $dao->$fld;
       }
     }
     return $row;
   }
 
-  /*
+  /**
    * Wrapper for calling values with fresh set to true to empty the given value
    *
    * Since there appears to be some inconsistency
@@ -616,12 +642,11 @@ WHERE  v.option_group_id = g.id
    * (for example CRM_Contribution_Pseudoconstant::paymentInstrument doesn't specify isActive
    * which is part of the cache key
    * will do a couple of variations & aspire to someone cleaning it up later
-   */
-  /**
-   * @param $name
+   *
+   * @param string $name
    * @param array $params
    */
-  static function flush($name, $params = array()){
+  public static function flush($name, $params = array()) {
     $defaults = array(
       'flip' => FALSE,
       'grouping' => FALSE,
@@ -653,10 +678,9 @@ WHERE  v.option_group_id = g.id
     );
   }
 
-  static function flushAll() {
+  public static function flushAll() {
     self::$_values = array();
     self::$_cache = array();
     CRM_Utils_Cache::singleton()->flush();
   }
 }
-