Updated the timeout to 500ms.
[civicrm-core.git] / CRM / Utils / Array.php
index 99a7fd7018af04cbd50f6f0e6b17b7fa6fbd71be..80b38b5eaeba9fac0cea09ecb70dc0d54279d800 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
  * Provides a collection of static methods for array manipulation.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 class CRM_Utils_Array {
 
@@ -238,9 +238,7 @@ class CRM_Utils_Array {
         self::flatten($value, $flat, $newPrefix, $seperator);
       }
       else {
-        if (!empty($value)) {
-          $flat[$newPrefix] = $value;
-        }
+        $flat[$newPrefix] = $value;
       }
     }
   }
@@ -866,9 +864,13 @@ class CRM_Utils_Array {
    * This is necessary to preserve sort order when sending an array through json_encode.
    *
    * @param array $associative
+   *   Ex: ['foo' => 'bar'].
    * @param string $keyName
+   *   Ex: 'key'.
    * @param string $valueName
+   *   Ex: 'value'.
    * @return array
+   *   Ex: [0 => ['key' => 'foo', 'value' => 'bar']].
    */
   public static function makeNonAssociative($associative, $keyName = 'key', $valueName = 'value') {
     $output = array();
@@ -1037,19 +1039,10 @@ class CRM_Utils_Array {
    * @param string $valueField
    *   Ex: 'value'.
    * @return array
-   *   Ex: array(
-   *     0 => array('key' => 'foo', 'value' => 'bar')
-   *   ).
+   * @deprecated
    */
   public static function toKeyValueRows($array, $keyField = 'key', $valueField = 'value') {
-    $result = array();
-    foreach ($array as $key => $value) {
-      $result[] = array(
-        $keyField => $key,
-        $valueField => $value,
-      );
-    }
-    return $result;
+    return self::makeNonAssociative($array, $keyField, $valueField);
   }
 
   /**
@@ -1172,55 +1165,4 @@ class CRM_Utils_Array {
     return NULL;
   }
 
-  /**
-   * Check if a key isset which may be several layers deep.
-   *
-   * This is a helper for when the calling function does not know how many layers deep the
-   * path array is so cannot easily check.
-   *
-   * @param array $array
-   * @param array $path
-   * @return bool
-   * @deprecated
-   */
-  public static function recursiveIsset($array, $path) {
-    return self::pathIsset($array, $path);
-  }
-
-  /**
-   * Check if a key isset which may be several layers deep.
-   *
-   * This is a helper for when the calling function does not know how many layers deep the
-   * path array is so cannot easily check.
-   *
-   * @param array $array
-   * @param array $path
-   *   An array of keys - e.g [0, 'bob', 8] where we want to check if $array[0]['bob'][8]
-   * @param mixed $default
-   *   Value to return if not found.
-   * @return bool
-   * @deprecated
-   */
-  public static function recursiveValue($array, $path, $default = NULL) {
-    return self::pathGet($array, $path, $default);
-  }
-
-  /**
-   * Append the value to the array using the key provided.
-   *
-   * e.g if value is 'llama' & path is [0, 'email', 'location'] result will be
-   * [0 => ['email' => ['location' => 'llama']]
-   *
-   * @param $path
-   * @param $value
-   * @param array $source
-   *
-   * @return array
-   * @deprecated
-   */
-  public static function recursiveBuild($path, $value, $source = []) {
-    self::pathSet($source, $path, $value);
-    return $source;
-  }
-
 }