INFRA-132 - phpcbf Drupal.WhiteSpace.ScopeIndent.IncorrectExact
[civicrm-core.git] / CRM / Core / OptionValue.php
index 1d7cf7fda12e098423ef17fa9e03d14a06d280c8..c7d695510cdf2995ada0c4ec7544d4c06be45c9c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -23,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_Core_OptionValue {
 
   /**
-   * static field for all the option value information that we can potentially export
+   * Static field for all the option value information that we can potentially export
    *
    * @var array
-   * @static
    */
   static $_exportableFields = NULL;
 
   /**
-   * static field for all the option value information that we can potentially export
+   * Static field for all the option value information that we can potentially export
    *
    * @var array
-   * @static
    */
   static $_importableFields = NULL;
 
   /**
-   * static field for all the option value information that we can potentially export
+   * Static field for all the option value information that we can potentially export
    *
    * @var array
-   * @static
    */
   static $_fields = NULL;
 
   /**
-   * Function to return option-values of a particular group
+   * Return option-values of a particular group
    *
-   * @param  array     $groupParams   Array containing group fields whose option-values is to retrieved.
-   * @param  string    $orderBy       for orderBy clause
-   * @param  array     $links         has links like edit, delete, disable ..etc
+   * @param array $groupParams
+   *   Array containing group fields whose option-values is to retrieved.
+   * @param array $links
+   *   Has links like edit, delete, disable ..etc.
+   * @param string $orderBy
+   *   For orderBy clause.
    *
-   * @return array of option-values
+   * @return array
+   *   Array of option-values
    *
-   * @access public
-   * @static
    */
-  static function getRows($groupParams, $links, $orderBy = 'weight') {
+  public static function getRows($groupParams, $links, $orderBy = 'weight') {
     $optionValue = array();
 
     $optionGroupID = NULL;
@@ -170,20 +169,20 @@ class CRM_Core_OptionValue {
   }
 
   /**
-   * Function to add/edit option-value of a particular group
+   * Add/edit option-value of a particular group
    *
-   * @param  array $params Array containing exported values from the invoking form.
-   * @param  array $groupParams Array containing group fields whose option-values is to retrieved/saved.
+   * @param array $params
+   *   Array containing exported values from the invoking form.
+   * @param array $groupParams
+   *   Array containing group fields whose option-values is to retrieved/saved.
    * @param $action
-   * @param  integer $optionValueID has the id of the optionValue being edited, disabled ..etc
+   * @param int $optionValueID Has the id of the optionValue being edited, disabled ..etc.
+   *   Has the id of the optionValue being edited, disabled ..etc.
    *
-   * @internal param string $orderBy for orderBy clause
    * @return CRM_Core_DAO_OptionValue
    *
-   * @access public
-   * @static
    */
-  static function addOptionValue(&$params, &$groupParams, &$action, &$optionValueID) {
+  public static function addOptionValue(&$params, &$groupParams, &$action, &$optionValueID) {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     // checking if the group name with the given id or name (in $groupParams) exists
     if (!empty($groupParams)) {
@@ -195,9 +194,9 @@ class CRM_Core_OptionValue {
     // if the corresponding group doesn't exist, create one, provided $groupParams has 'name' in it.
     if (!$optionGroup->id) {
       if ($groupParams['name']) {
-        $newOptionGroup   = CRM_Core_BAO_OptionGroup::add($groupParams, $defaults);
+        $newOptionGroup = CRM_Core_BAO_OptionGroup::add($groupParams, $defaults);
         $params['weight'] = 1;
-        $optionGroupID    = $newOptionGroup->id;
+        $optionGroupID = $newOptionGroup->id;
       }
     }
     else {
@@ -215,7 +214,7 @@ class CRM_Core_OptionValue {
       $fieldValues = array('option_group_id' => $optionGroupID);
       // use the next available value
       /* CONVERT(value, DECIMAL) is used to convert varchar
-               field 'value' to decimal->integer                    */
+      field 'value' to decimal->integer                    */
 
       $params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
         $fieldValues,
@@ -240,18 +239,21 @@ class CRM_Core_OptionValue {
   /**
    * Check if there is a record with the same name in the db
    *
-   * @param string $value the value of the field we are checking
-   * @param string $daoName the dao object name
-   * @param string $daoID the id of the object being updated. u can change your name
+   * @param string $value
+   *   The value of the field we are checking.
+   * @param string $daoName
+   *   The dao object name.
+   * @param string $daoID
+   *   The id of the object being updated. u can change your name.
    *                          as long as there is no conflict
-   * @param $optionGroupID
-   * @param string $fieldName the name of the field in the DAO
+   * @param int $optionGroupID
+   * @param string $fieldName
+   *   The name of the field in the DAO.
    *
-   * @return boolean     true if object exists
-   * @access public
-   * @static
+   * @return bool
+   *   true if object exists
    */
-  static function optionExists($value, $daoName, $daoID, $optionGroupID, $fieldName = 'name') {
+  public static function optionExists($value, $daoName, $daoID, $optionGroupID, $fieldName = 'name') {
     $object = new $daoName();
     $object->$fieldName = $value;
     $object->option_group_id = $optionGroupID;
@@ -270,17 +272,10 @@ class CRM_Core_OptionValue {
    * @param string $mode
    * @param string $contactType
    *
-   * @internal param string $value the value of the field we are checking
-   * @internal param string $daoName the dao object name
-   * @internal param string $daoID the id of the object being updated. u can change your name
-   *                          as long as there is no conflict
-   * @internal param string $fieldName the name of the field in the DAO
-   *
-   * @return boolean     true if object exists
-   * @access public
-   * @static
+   * @return bool
+   *   true if object exists
    */
-  static function getFields($mode = '', $contactType = 'Individual') {
+  public static function getFields($mode = '', $contactType = 'Individual') {
     $key = "$mode $contactType";
     if (empty(self::$_fields[$key]) || !self::$_fields[$key]) {
       self::$_fields[$key] = array();
@@ -305,7 +300,11 @@ class CRM_Core_OptionValue {
         //the fields email greeting and postal greeting are meant only for Individual and Household
         //the field addressee is meant for all contact types, CRM-4575
         if (in_array($contactType, array(
-          'Individual', 'Household', 'Organization', 'All'))) {
+          'Individual',
+          'Household',
+          'Organization',
+          'All',
+        ))) {
           $nameTitle = array(
             'addressee' => array(
               'name' => 'addressee',
@@ -345,14 +344,13 @@ class CRM_Core_OptionValue {
   }
 
   /**
-   * build select query in case of option-values
+   * Build select query in case of option-values
    *
    * @param $query
    *
    * @return void
-   * @access public
    */
-  static function select(&$query) {
+  public static function select(&$query) {
     if (!empty($query->_params) || !empty($query->_returnProperties)) {
       $field = self::getFields();
       foreach ($field as $name => $values) {
@@ -372,22 +370,24 @@ class CRM_Core_OptionValue {
   }
 
   /**
-   * Function to return option-values of a particular group
+   * Return option-values of a particular group
    *
-   * @param  array     $groupParams   Array containing group fields
+   * @param array $groupParams
+   *   Array containing group fields.
    *                                  whose option-values is to retrieved.
-   * @param  array     $values        (reference) to the array which
+   * @param array $values
+   *   (reference) to the array which.
    *                                  will have the values for the group
-   * @param  string    $orderBy       for orderBy clause
+   * @param string $orderBy
+   *   For orderBy clause.
    *
-   * @param  boolean   $isActive      do you want only active option values?
+   * @param bool $isActive Do you want only active option values?
    *
-   * @return array of option-values
+   * @return array
+   *   Array of option-values
    *
-   * @access public
-   * @static
    */
-  static function getValues($groupParams, &$values, $orderBy = 'weight', $isActive = FALSE) {
+  public static function getValues($groupParams, &$values, $orderBy = 'weight', $isActive = FALSE) {
     if (empty($groupParams)) {
       return NULL;
     }
@@ -454,5 +454,5 @@ FROM
       );
     }
   }
-}
 
+}